sirthias / borer

Efficient CBOR and JSON (de)serialization in Scala

Home Page:https://sirthias.github.io/borer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug in borer-derivation? deriveCodec fails to compile when using type alias

MarconZet opened this issue · comments

type Foo = String
case class Bar(bar: Foo)
implicit val barCodec: Codec[Bar] = deriveCodec

fails build with:

[error] MyBorerAkkaSerializer.scala:54:39: value writeMyBorerAkkaSerializer.this.Foo is not a member of io.bullet.borer.Writer
[error]   implicit val barCodec: Codec[Bar] = deriveCodec

Expected behaviour: Build successful

I found a workaround with:

implicit val barCodec: Codec[Bar] = Codec(
  Encoder.from(Bar.unapply _),
  Decoder.from(Bar.apply _)
)

but that's far from an elegant solution.

Ok, thank you for reporting.
I happen to have time right now to look at this and will do so right away...

Thank you, @MarconZet, for reporting.
The fix is already in the master branch.
Would you like a quick patch release to unblock this issue on your side?

We'd appreciate a patch release :)

Ok, just pushed borer 1.7.1 to sonatype.
You can pull it from there or wait for the sync to maven central, which is probably going to take a few hours though...
Thanks again for reporting!

Wow that's one of the fastest report-to-release cycles I've seen in OSS so far ❤️

:)
It was just a lucky coincidence that the bug report hit a perfect break between things on my side.
I'm glad that borer works out for your setup!

Actually, FYI, as you've probably noticed, we're working on ready-to-use serializer for Akka messages/event/states, since Jackson that's suggested by Akka docs is a joke (surprising runtime failures, no support for Scala objects/ADTs etc.) 😅

Are you aware of any work that has been already done in that direction? There's borer-akka-compat but AFAICS it doesn't provide a ready Serializer, just Codecs for ActorRefs etc.

Also @sirthias ... would it be possible to retain support for Scala 2.12 in 1.7+? Since AFAICS 1.7.0 and 1.7.1 have only been published for 2.13 ://

There's borer-akka-compat but AFAICS it doesn't provide a ready Serializer, just Codecs for ActorRefs etc.

Yes. The reason is that we haven't needed these things ourselves yet.
I'd be happy to review and merge any PRs if you want to submit any...

Great! We're prototyping that as a separate project for convenience as for now, but it makes sense to integrate it back into main borer repo... opened VirtusLab/akka-serialization-helper#18 for that

@PawelLipski We are using borer for akka-serialization using the pattern mentioned here.

@mushtaq actually! since you're using Borer for a bit longer than us... do you have any experiences with migrating Akka events when Borer is used as a serializer (or any other library, for that matter)?

Unfortunately, no. So far, we do not have to deal persisting these events.

I just came across transducers in latest version of borer. Will that help?

Looks promising! Let us take a look 👁️