avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
188 stars 36 forks source link

Beautify the Avro api entrypoint #163

Closed Chuckame closed 2 months ago

Chuckame commented 10 months ago

Currently, to do common stuff, we have to start by Avro.default. But when we want to override defaults, we do like this:

Avro(SerializersModule {
    contextual(...)
}, AvroConfiguration(
    namingStrategy = ...
))

kolinx serialization Json (and other official supported formats) are doing very interesting stuff, here the examples:

// default way
Json.encodeToByteArray(...)

// customized way
Json {
   serializersModule = SerializersModule {
    contextual(...)
   }
    namingStrategy = ...
}.encodeToByteArray(...)

It would be great to do it ! It's not that complex to implement, it's mainly copy/paste from Json class

thake commented 9 months ago

I think this is a good starting point for our API remake that is required for moving avro4k to multiplatform :rocket:

thake commented 9 months ago

@Chuckame, can you make a draft in a PR? It does not have to compile, just to showcase how the API would look like.

Chuckame commented 2 months ago

Done in #186