Custom EntityStreamingSupport

I’m trying to create a new implementation of EntityStreamingSupport.

Here is my actual code:

class ChecksumStreamingSupport private[akka](
                                              maxObjectSize: Int,
                                              val supported: ContentTypeRange,
                                              val contentType: ContentType,
                                              val framingRenderer: Flow[ByteString, ByteString, NotUsed],
                                              val parallelism: Int,
                                              val unordered: Boolean
                                            ) extends EntityStreamingSupport {

  def this(maxObjectSize: Int) =
      Flow[ByteString].intersperse(ByteString("["), ByteString(","), ByteString("]")),
      1, false)

  override def framingDecoder: Flow[ByteString, ByteString, NotUsed] = ???

  override def withSupported(range: jm.ContentTypeRange): EntityStreamingSupport = new ChecksumStreamingSupport(maxObjectSize, range, contentType, framingRenderer, parallelism, unordered)

  override def withContentType(contentType: jm.ContentType): EntityStreamingSupport = new ChecksumStreamingSupport(maxObjectSize, supported, contentType, framingRenderer, parallelism, unordered)

  override def withParallelMarshalling(parallelism: Int, unordered: Boolean): EntityStreamingSupport = ???

The problem is I can’t use the #asScala method. To translate Java components to Scala because the import akka.http.impl.util.JavaMapping class is unaccessible. (The prodived code is based on the ScalaDSL’s JsonStreamingEntitySupport)

So I’m asking for a workaround or link to the unfound documentation part.

Have a good day !

Edit: this new implementation is to serialize a checkum so a binary format.

Hi @Iltotore,

I see, that’s unfortunate indeed. In most cases, you can just try casting from the javadsl version to the scaladsl version since the Scala version usually extends the Java side. I guess it would be nice if we would provide toScala methods directly on the Java side. I created to track that idea.


1 Like