Skip to content
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

Merged
merged 6 commits into from
Oct 25, 2024
Merged

Conversation

kkondaka
Copy link
Collaborator

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

  • [X ] New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • [ X] Commits are signed with a real name per the DCO

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.

* @return returns the builder
* @since 2.10
*/
public Builder<T> withEventHandle(final EventHandle eventHandle) {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Member

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.

Copy link
Member

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;
Copy link
Member

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().

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for using sameInstance!

@kkondaka kkondaka requested a review from sb2k16 as a code owner October 24, 2024 18:16
dlvenable
dlvenable previously approved these changes Oct 24, 2024
Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

sb2k16
sb2k16 previously approved these changes Oct 24, 2024
Signed-off-by: Kondaka <[email protected]>
@kkondaka kkondaka dismissed stale reviews from sb2k16 and dlvenable via 3ef52e0 October 24, 2024 23:49
@kkondaka kkondaka merged commit 331011c into opensearch-project:main Oct 25, 2024
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants