-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event with handle #4952
Event with handle #4952
Conversation
Signed-off-by: Kondaka <[email protected]>
Signed-off-by: Kondaka <[email protected]>
Signed-off-by: Kondaka <[email protected]>
7155c44
to
5e30e30
Compare
* @return returns the builder | ||
* @since 2.10 | ||
*/ | ||
public Builder<T> withEventHandle(final EventHandle eventHandle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be part of BaseEventBuilder
. I'm also tempted to say that we only support it in there by making this particular function package protected, but that may also be a bit of work to accomplish.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, as this is going to be used primarily by the aggregate
processor, I think it would be reasonable to expose this only in BaseEventBuilder
. You won't have to change every source. Just change that one processor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to make this change to use BaseEventBuilder in aggregate processor now or can it be part of a future PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add BaseEventBuilder
in this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you can make this package protected for this PR. Either way.
@@ -532,10 +536,11 @@ public static JacksonEvent fromEvent(final Event event) { | |||
public abstract static class Builder<T extends Builder<T>> { | |||
|
|||
private EventMetadata eventMetadata; | |||
private Object data; | |||
protected Object data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to expose this further?
If you do need it, you should have a protected getter: protected Object getData()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I do need it because I am exposing it to derived classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I need it so that I can modify it directly from derived classes, getData() does not work. I can add setData()
but I think it makes sense to actually use protected
member so that derived classes can directly modify it. I think it makes sense in this case. Let me know what you think. The current code is broken in the sense that JacksonMetric
has it's own data
which is different from parent class's data
and that is problematic in some cases.
@@ -860,6 +875,7 @@ void fromEvent_with_a_JacksonEvent() { | |||
assertThat(createdEvent, notNullValue()); | |||
assertThat(createdEvent, not(sameInstance(originalEvent))); | |||
assertThat(event.getEventHandle(), is(notNullValue())); | |||
assertTrue(event.getEventHandle() instanceof DefaultEventHandle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assertTrue(event.getEventHandle() instanceof DefaultEventHandle); | |
assertThat(event.getEventHandle(), instanceOf(DefaultEventHandle.class)); |
This will give a better error message if the type is incorrect. It will include the actual type.
builder.withEventHandle(eventHandle); | ||
sum = builder.build(); | ||
final EventHandle handle = sum.getEventHandle(); | ||
assertThat(handle, is(sameInstance(eventHandle))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for using sameInstance
!
Signed-off-by: Kondaka <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Signed-off-by: Kondaka <[email protected]>
Signed-off-by: Kondaka <[email protected]>
Description
Added
withEventHandle
API to JacksonEvent.Builder.This is part of supporting acknowledgements to events generated by aggregate processor
Issues Resolved
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.