akka-http-json icon indicating copy to clipboard operation
akka-http-json copied to clipboard

Consuming akka-http JSON streaming does not seem to work with akka-http-circe

Open akauppi opened this issue 6 years ago • 6 comments

I got server side working, but have problems with the client side.

https://doc.akka.io/docs/akka-http/current/common/json-support.html#consuming-json-streaming-style-apis

The akka-http samples are made with Spray-json. I'm trying to replicate the same, using Circe and akka-http-circe.

Note: This is just an early warning. Looking into what's the problem, precisely (so I can expose a repo that showcases it, in a few days).

akauppi avatar May 02 '18 13:05 akauppi

The code is available (I'm implying I could use some help...) here: https://github.com/akauppi/akka-http-circe-streaming-sample

Compilation fails with:

Error:(54, 54) could not find implicit value for parameter um: akka.http.scaladsl.unmarshalling.Unmarshaller[akka.util.ByteString,sandbox.Data]
            .mapAsync(1)(bytes => Unmarshal(bytes).to[Data])
Error:(54, 54) not enough arguments for method to: (implicit um: akka.http.scaladsl.unmarshalling.Unmarshaller[akka.util.ByteString,sandbox.Data], implicit ec: scala.concurrent.ExecutionContext, implicit mat: akka.stream.Materializer)scala.concurrent.Future[sandbox.Data].
Unspecified value parameters um, mat.
            .mapAsync(1)(bytes => Unmarshal(bytes).to[Data])

akauppi avatar May 03 '18 11:05 akauppi

Thanks. I don't have the time to investigate this now. BTW, for you use case you might also take a look at Server-Sent Events and in particular to the SSE support in Alpakka.

hseeberger avatar May 03 '18 12:05 hseeberger

No problem. I got the hop running, and my question rather is whether you see this to be within the scope of akka-http-circe, or not.

I hope you do. :) Akka-http-json is the "go to" place for integrating e.g. Circe with akka-http, and it's so nice when things just work. Since Akka HTTP now provides support for JSON streaming (and since the server side already works), it would make sense to allow also the client side to do so.

For me, that meant doing this unmarshaller (link).

I don't have the chance to make a proper PR right now, but if you see the feature as a welcome inclusion, I may do so later (within some weeks, or a month).

akauppi avatar May 03 '18 12:05 akauppi

Yeah, entity streaming is definitely a missing feature. Please give it a try.

hseeberger avatar May 03 '18 12:05 hseeberger

Thanks for mentioning Server-Sent Events. I may be using those in my actual case, but let's return to this at some point.

akauppi avatar May 06 '18 07:05 akauppi

I guess #347 solved this issue.

gabfssilva avatar Jan 08 '20 23:01 gabfssilva