sdk-java icon indicating copy to clipboard operation
sdk-java copied to clipboard

Modularization: avro module

Open fabiojose opened this issue 4 years ago • 14 comments

This module implements the Avro Event Format.

  • avro

This module depend on api one.

When someone wants the avro format to create or read events, they add this module and they concern about potential conflicts with pre-existing dependencies in their projects.

fabiojose avatar Apr 15 '20 13:04 fabiojose

@slinkydeveloper: I do have implementation of EventFormat interface for avro. However, the implementation class has a setter method for Avro schema since this not defined in EventFormat interface. Hence, following code would be used to get hold of format and serialize.

AvroFormat avroFormat = (AvroFormat) EventFormatProvider
        .getInstance()
        .resolveFormat(AvroFormat.CONTENT_TYPE);
//Set avro schema
avroFormat.setSchema(schema)

Let me know your thoughts.

subanasif avatar Dec 11 '20 06:12 subanasif

avroFormat.setSchema(schema)

Which schema?

slinkydeveloper avatar Dec 11 '20 07:12 slinkydeveloper

This is avro schema. That is org.apache.avro.Schema. This could be coming from filesystem or remote repository like schema registry.

subanasif avatar Dec 11 '20 07:12 subanasif

avro schema of what? of Cloudevents? The one from the spec https://github.com/cloudevents/spec/blob/v1.0/spec.avsc?

slinkydeveloper avatar Dec 11 '20 07:12 slinkydeveloper

Thats correct. It *.avsc schema

subanasif avatar Dec 11 '20 07:12 subanasif

Shouldn't this be loaded statically? Can we ship this schema as a resource in the package and then load it statically?

slinkydeveloper avatar Dec 11 '20 08:12 slinkydeveloper

The schema at https://github.com/cloudevents/spec/blob/v1.0/spec.avsc is just a spec, whereas real schema would have much more details (in data part, with specific field definitions). Hence loading statically as resource won't work. More often, these spec compliant schemas are stored at third-party registries.

subanasif avatar Dec 11 '20 08:12 subanasif

TBH I'm not an expert of avro, so I can't tell. What I can say is that it sounds weird to me to mutate the internal state of EventFormat in order to provide a custom schema... My expectation is that EventFormat doesn't parse the body, but it just collects it in a raw form (like in json, where it collects the data as json node) and then the user process this raw data into the pojo she/he wants to. I think you should check out this PR where they're working on improving the schema https://github.com/cloudevents/spec/pull/613

slinkydeveloper avatar Dec 11 '20 08:12 slinkydeveloper

@subanasif https://github.com/cloudevents/spec/blob/v1.0/spec.avsc is compiled into Java before shipping, so dynamically loading it is not necessary (although possible). That Avro spec is used by other CE clients, so I don't think it can be changed as long as compatibility with CE 1.0 is desired.

yuce avatar Dec 11 '20 11:12 yuce

@subanasif https://github.com/cloudevents/spec/blob/v1.0/spec.avsc is compiled into Java before shipping, so dynamically loading it is not necessary (although possible). That Avro spec is used by other CE clients, so I don't think it can be changed as long as compatibility with CE 1.0 is desired.

I'm not sure that's what is being suggested. @subanasif you mentioned you had an implementation, any chance you could share it for some more context?

pdebuitlear avatar Jan 24 '21 23:01 pdebuitlear

any update on this issue?

pdebuitlear avatar Apr 18 '21 09:04 pdebuitlear

Is there any update on if/when this will be released?

alsonlu avatar Jun 28 '21 19:06 alsonlu

This is just waiting for a contribution to come :smile:

slinkydeveloper avatar Jun 29 '21 08:06 slinkydeveloper

Just let you know I have been working on an avro serde impl these days.

sunng87 avatar Jul 16 '21 06:07 sunng87