-
Notifications
You must be signed in to change notification settings - Fork 16
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
Suggestion: Codec for unions to help Akka serialization #161
Comments
I see what you mean. Also, note that you can replace w.write(Map(nameOf[T1] -> x)) with w.writeMapOpen(1).writeString(nameOf[T1]).write(x).writeMapClose() and avoid the intermediate |
Given that macros will need rework after Scala-3, our team has decided to not implement any in our projects. (But library macros are kosher :-) I thought this will be more of For now, we have take a simpler approach. Sharing an example of that pattern for those who may want to use borer with Akka:
If we see perf issues, we may use reflection to replace List to a Map as done on a branch version of CborAkkaSerializer So, you can close the issue if adding a |
Very interesting! Thank you, @mushtaq, for the pointers to your solution! Since the problem appears to be a more general one that isn't quite specific to borer, I'm indeed inclined to not generate more boilerplate on borer's side at this point. However, I'm gonna keep this issue open for some time to maybe attract more feedback/comments from other users. |
You are right about the blogpost, thanks. Our team will soon write it up. |
Based on the Akka Serializer pattern described in this issue, we have written a blog post - How to write your own Borer based Akka Serializer !!!. It covers our journey of evolving the Akka serializer pattern using Borer. |
Thank you for the pointer, @skvithalani! |
Akka has a pattern for specifying serializers: first specify the serializer in
akka.actor.serializers
setting and then bind it with the types inakka.actor.serialization-bindings
.To avoid doing this for each top-level ADT, we mark every top-level ADT with a marker trait. This allows us to write just one serializer per application.
I am wondering if borer can help simplify writing this serializer by providing a utility to write codec for this
Marker
trait (which can not be a sealed). One way will be by providing forUnion helpers like below.The text was updated successfully, but these errors were encountered: