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

Avro format implementation #407

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

sunng87
Copy link

@sunng87 sunng87 commented Jul 16, 2021

This patch is to provide an Avro format implementation for the CloudEvent 1.0.

Fixes #115

TODO items:

  • unit tests
  • extension fields?
  • data

Signed-off-by: Ning Sun <sunng@protonmail.com>
Signed-off-by: Ning Sun <sunng@protonmail.com>
Signed-off-by: Ning Sun <sunng@protonmail.com>
Signed-off-by: Ning Sun <sunng@protonmail.com>
Signed-off-by: Ning Sun <sunng@protonmail.com>
Signed-off-by: Ning Sun <sunng@protonmail.com>
@sunng87 sunng87 force-pushed the feature/avro branch 2 times, most recently from fca0a76 to 0e4cc31 Compare July 17, 2021 15:10
Signed-off-by: Ning Sun <sunng@protonmail.com>
Signed-off-by: Ning Sun <sunng@protonmail.com>
@sunng87 sunng87 marked this pull request as ready for review July 19, 2021 08:18
@tompoch
Copy link

tompoch commented Jul 20, 2021

What is the relation of this to the content mode as defined in the Kafka Protocol Binding? Do I read correctly that this PR corresponds to the structured mode, but not to the binary?

@tompoch
Copy link

tompoch commented Jul 20, 2021

I would expect some reference to the schema-registry maintaining the avro schemas. Am I missing something?

@sunng87
Copy link
Author

sunng87 commented Jul 22, 2021

This patch is to implement Avro as a cloudevent serialization format. It doesn't cover kafka binding for now. Perhaps we can provide that integration in future.

@pierDipi pierDipi self-assigned this Nov 3, 2021
@pierDipi pierDipi self-requested a review November 3, 2021 07:47
@pierDipi pierDipi removed their assignment Nov 3, 2021
Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

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

Awesome @sunng87!

I left some comments/questions/suggestions.

Comment on lines 38 to 41
public AvroCloudEventDataWrapper(Map<String, Object> data) {
avroCloudEventData = new AvroCloudEventData();
avroCloudEventData.setValue(data);
}
Copy link
Member

Choose a reason for hiding this comment

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

Can we inject AvroCloudEventData directly?

Suggested change
public AvroCloudEventDataWrapper(Map<String, Object> data) {
avroCloudEventData = new AvroCloudEventData();
avroCloudEventData.setValue(data);
}
public AvroCloudEventDataWrapper(AvroCloudEventData avroCloudEventData) {
this.avroCloudEventData = Objects.requireNonNull(avroCloudEventData);
}

Copy link
Author

Choose a reason for hiding this comment

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

The reason I'm using a map here is I tried to avoid exposing generated data type in a public api. The AvroCloudEventData contains some Avro serialization logic.

Copy link
Member

Choose a reason for hiding this comment

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

OK, sounds good!

Can we add only the Objects.requireNonNull check?

Suggested change
public AvroCloudEventDataWrapper(Map<String, Object> data) {
avroCloudEventData = new AvroCloudEventData();
avroCloudEventData.setValue(data);
}
public AvroCloudEventDataWrapper(Map<String, Object> data) {
avroCloudEventData = new AvroCloudEventData();
avroCloudEventData.setValue(Objects.requireNonNull(data));
}

formats/avro/pom.xml Outdated Show resolved Hide resolved
Map<String, Object> testData = Map.of("name", "Ning", "age", 22.0);

@Test
public void testSerde() {
Copy link
Member

Choose a reason for hiding this comment

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

Can we add more test cases?

Copy link
Author

Choose a reason for hiding this comment

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

Ok. I will do it in next few commits.

formats/avro/pom.xml Outdated Show resolved Hide resolved
formats/avro/src/main/avro/spec.avsc Outdated Show resolved Hide resolved
Signed-off-by: Ning Sun <sunng@protonmail.com>
@sunng87 sunng87 force-pushed the feature/avro branch 2 times, most recently from d9fe8c4 to 37c4a56 Compare November 11, 2021 16:07
Signed-off-by: Ning Sun <sunng@protonmail.com>
@pierDipi pierDipi added this to Review in progress in SDK Java Nov 14, 2021
@pierDipi pierDipi moved this from Review in progress to In progress in SDK Java Dec 7, 2021
@pkgonan
Copy link

pkgonan commented Mar 31, 2022

@sunng87 @pierDipi Hi. Any changes of this pr?

@sunng87
Copy link
Author

sunng87 commented Mar 31, 2022

hi @pkgonan I'm no longer working on this. Feel free to fork and continue this work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
SDK Java
In progress
Development

Successfully merging this pull request may close these issues.

Modularization: avro module
4 participants