avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
194 stars 37 forks source link

Reworked Avro encoding and decoding API #75

Closed thake closed 3 years ago

thake commented 3 years ago

Reworked Avro encoding and decoding API in order to have type safety for required encoding / decoding settings.

The following code would perfectly compile:

val input = openInputStream<T>(serializer) {
    format = AvroFormat.BinaryFormat
}

but at runtime an exception will be thrown because the readerSchema needs to be set for BinaryFormat.

To prevent this wrong API usage, the API has been redesigned so that the compiler can detect these errors. The call would look like this with the new API:


val input = openInputStream<T>(serializer) {
   decodeFormat = AvroDecodeFormat.Binary(mySchema)
}
thake commented 3 years ago

@sksamuel I changed the API a little bit and removed the deprecated bits. As you designed the API, I would be very happy if you can take a look at the changes.

thake commented 3 years ago

Hey @sksamuel, do you think you'll have the time to look at this PR? Otherwise, I will just go forward and merge this PR soon.

sksamuel commented 3 years ago

If you're happy to merge it, then please do. I'm back from vacation now, and just catching up. I will setup the creds tomorrow or Tuesday and add github actions to release.

On Sun, 8 Nov 2020 at 22:31, Thorsten Hake notifications@github.com wrote:

Hey @sksamuel https://github.com/sksamuel, do you think you'll have the time to look at this PR? Otherwise, I will just go forward and merge this PR soon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/avro-kotlin/avro4k/pull/75#issuecomment-723747246, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFVSGUWVNZ3L7HUSK2AMR3SO5WBBANCNFSM4SWQLJDQ .