avro-kotlin / avro4k-arrow

Apache License 2.0
2 stars 1 forks source link

Multiplatform Support #1

Open mysticfall opened 2 years ago

mysticfall commented 2 years ago

I've recently started a Kotlin/JS project which relies on Arrows and found that there's no serialisers available for the type classes it provides that works on JS platform.

It'd be nice if this library could be also published for other platforms than JVM. KotlinX serialization itself works great on JS, so I suspect it could be done without too much difficulty.

Thanks!

thake commented 2 years ago

@mysticfall thanks for posting this feature request.

Sadly this is not as trivial as it seems. Avro4k relies on the Avro java library for serialization purposes. So you can see it as a compatibility layer between avro and kotlinx.serialization. To support javascript as another platform, one would need to write a separate javascript integration layer with an unofficial avro javascript library as a replacement for the java avro library. I think the main obstacle will be to replace the Avro classes used in the API of avro4k with platform unspecific types.

If you want to give it a try, go ahead :) The library https://github.com/mtth/avsc looks promising.

mysticfall commented 2 years ago

Ah, I didn't realise that the library has a Java dependency. My data classes only uses Option<T> so I only checked OptionSerializer before I created the issue.

I think I'll take just the relevant serialiser class from your project for now (with proper credits, of course). Thanks for the explanation, and also for the great work!