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
Boopickle encoders #1826
Boopickle encoders #1826
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say this goes into the class of things we probably want to spin off at 1.x, but could find a home here while we finish evolving.
* Create an `EntityDecoder` for `A` given a `Pickler[A]` | ||
*/ | ||
def booOf[F[_]: Sync, A: Pickler]: EntityDecoder[F, A] = | ||
EntityDecoder.decodeBy(MediaType.`application/octet-stream`)(booDecoderByteBuffer[F, A]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be hard to use, like jsonOf
became hard to use in 0.18, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure what you mean, could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used to be able to say req.as(jsonOf(Foo])
. But the extra evidence parameter made that something awful like req.as(jsonOf(implicitly, Decoder[Foo]))
. So we added decodeJson
syntax to Message
to make it req.decodeJson[Foo]
.
Isn't boo going to suffer the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I noted decodeJson
was on Message
but I assumed it was grandfathered. OTOH I don't think you want to keep adding decodeXXX
methods. Or perhaps they can be extension methods in the bundle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like decodeJson
. We just never figured out a better way, since we don't have multiple implicit lists.
I think if we did the same here, it would go in the bundle.
} | ||
} | ||
|
||
checkAll("EntityCodec[IO, Json]", EntityCodecTests[IO, Fruit].entityCodec) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label is wrong on this test
build.sbt
Outdated
Http4sPlugin.boopickle | ||
) | ||
) | ||
.dependsOn(core, testing % "test->test", jawn % "compile;test->test") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this module depend on jawn?
New modules need to opt out of MiMa checking, because there isn't a prior version to check against. I think there is an example of this in the Netty PR. |
libraryDependencies ++= Seq( | ||
Http4sPlugin.boopickle | ||
), | ||
mimaPreviousArtifacts := Set.empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remember to remove this after we release 0.18.11.
We use boopickle on our application with the encoders in this PR. I thought this could be generally useful in http4s though I'm not sure how widely used
boopickle
is.This is also an opportunity, to receive any criticism you may have to my implementation. In particular I'm not sure if there is enough testing
I couldn't find an aggregate on
build.sbt
to include this into the overall build. Is it needed?