Class JsonEntityStreamingSupport
- java.lang.Object
-
- akka.http.javadsl.common.EntityStreamingSupport
-
- akka.http.scaladsl.common.EntityStreamingSupport
-
- akka.http.javadsl.common.JsonEntityStreamingSupport
-
- akka.http.scaladsl.common.JsonEntityStreamingSupport
-
public final class JsonEntityStreamingSupport extends JsonEntityStreamingSupport
-
-
Constructor Summary
Constructors Constructor Description JsonEntityStreamingSupport(int maxObjectSize)
JsonEntityStreamingSupport(int maxObjectSize, ContentTypeRange supported, ContentType contentType, akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> framingRenderer, int parallelism, boolean unordered)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ContentType
contentType()
Write-side, defines what Content-Type the Marshaller should offer and the final Content-Type of the response.akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed>
framingDecoder()
Read-side, decode incoming framed entity.akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed>
framingRenderer()
Write-side, apply framing to outgoing entity stream.int
parallelism()
Write-side / read-side, defines if (un)marshalling should be done in parallel.ContentTypeRange
supported()
Read-side, what content types it is able to frame and unmarshall.java.lang.String
toString()
boolean
unordered()
Write-side / read-side, defines if (un)marshalling should preserve ordering of incoming stream elements.JsonEntityStreamingSupport
withContentType(ContentType ct)
Write-side, defines what Content-Type the Marshaller should offer and the final Content-Type of the response.JsonEntityStreamingSupport
withFramingRenderer(akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> framingRendererFlow)
JsonEntityStreamingSupport
withFramingRendererFlow(akka.stream.javadsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> framingRendererFlow)
Java API: Write-side, apply framing to outgoing entity stream.JsonEntityStreamingSupport
withParallelMarshalling(int parallelism, boolean unordered)
Write-side / read-side, defines parallelism and if ordering should be preserved or not of Source element marshalling.JsonEntityStreamingSupport
withSupported(ContentTypeRange range)
Read-side, allows changing what content types are accepted by this framing.-
Methods inherited from class akka.http.scaladsl.common.EntityStreamingSupport
csv, csv, getFramingDecoder, getFramingRenderer, json, json
-
-
-
-
Constructor Detail
-
JsonEntityStreamingSupport
public JsonEntityStreamingSupport(int maxObjectSize, ContentTypeRange supported, ContentType contentType, akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> framingRenderer, int parallelism, boolean unordered)
-
JsonEntityStreamingSupport
public JsonEntityStreamingSupport(int maxObjectSize)
-
-
Method Detail
-
contentType
public ContentType contentType()
Description copied from class:EntityStreamingSupport
Write-side, defines what Content-Type the Marshaller should offer and the final Content-Type of the response.- Specified by:
contentType
in classEntityStreamingSupport
-
framingDecoder
public akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> framingDecoder()
Description copied from class:EntityStreamingSupport
Read-side, decode incoming framed entity. For example with an incoming JSON array, chunk it up into JSON objects contained within that array.- Specified by:
framingDecoder
in classEntityStreamingSupport
- Returns:
- (undocumented)
-
framingRenderer
public akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> framingRenderer()
Description copied from class:EntityStreamingSupport
Write-side, apply framing to outgoing entity stream.Most typical usage will be a variant of
Flow[ByteString].intersperse
.For example for rendering a JSON array one would return
Flow[ByteString].intersperse(ByteString("["), ByteString(","), ByteString("]"))
and for rendering a new-line separated CSV simplyFlow[ByteString].intersperse(ByteString("\n"))
.- Specified by:
framingRenderer
in classEntityStreamingSupport
- Returns:
- (undocumented)
-
parallelism
public int parallelism()
Description copied from class:EntityStreamingSupport
Write-side / read-side, defines if (un)marshalling should be done in parallel.This may be beneficial marshalling the bottleneck in the pipeline.
See also
EntityStreamingSupport.parallelism()
andEntityStreamingSupport.withParallelMarshalling(int,boolean)
.- Specified by:
parallelism
in classEntityStreamingSupport
- Returns:
- (undocumented)
-
supported
public ContentTypeRange supported()
Description copied from class:EntityStreamingSupport
Read-side, what content types it is able to frame and unmarshall.- Specified by:
supported
in classEntityStreamingSupport
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
unordered
public boolean unordered()
Description copied from class:EntityStreamingSupport
Write-side / read-side, defines if (un)marshalling should preserve ordering of incoming stream elements.Allowing for parallel and unordered (un)marshalling often yields higher throughput and also allows avoiding head-of-line blocking if some elements are much larger than others.
See also
EntityStreamingSupport.parallelism()
andEntityStreamingSupport.withParallelMarshalling(int,boolean)
.- Specified by:
unordered
in classEntityStreamingSupport
- Returns:
- (undocumented)
-
withContentType
public JsonEntityStreamingSupport withContentType(ContentType ct)
Description copied from class:EntityStreamingSupport
Write-side, defines what Content-Type the Marshaller should offer and the final Content-Type of the response.EntityStreamingSupport traits MUST support re-configuring the offered
ContentType
. This is due to the need integrating with existing systems which sometimes expect custom Content-Types, however really are just plain JSON or something else internally (perhaps with slight extensions).NOTE: Implementations should specialize the return type to their own Type!
- Specified by:
withContentType
in classEntityStreamingSupport
- Parameters:
ct
- (undocumented)- Returns:
- (undocumented)
-
withFramingRenderer
public JsonEntityStreamingSupport withFramingRenderer(akka.stream.scaladsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> framingRendererFlow)
-
withFramingRendererFlow
public JsonEntityStreamingSupport withFramingRendererFlow(akka.stream.javadsl.Flow<akka.util.ByteString,akka.util.ByteString,akka.NotUsed> framingRendererFlow)
Description copied from class:JsonEntityStreamingSupport
Java API: Write-side, apply framing to outgoing entity stream.Most typical usage will be a variant of
Flow[ByteString].intersperse
.For example for rendering a JSON array one would return
Flow[ByteString].intersperse(ByteString("["), ByteString(","), ByteString("]"))
and for rendering a new-line separated CSV simplyFlow[ByteString].intersperse(ByteString("\n"))
.- Specified by:
withFramingRendererFlow
in classJsonEntityStreamingSupport
- Parameters:
framingRendererFlow
- (undocumented)- Returns:
- (undocumented)
-
withParallelMarshalling
public JsonEntityStreamingSupport withParallelMarshalling(int parallelism, boolean unordered)
Description copied from class:EntityStreamingSupport
Write-side / read-side, defines parallelism and if ordering should be preserved or not of Source element marshalling.Sometimes marshalling multiple elements at once (esp. when elements are not evenly sized, and ordering is not enforced) may yield in higher throughput.
NOTE: Implementations should specialize the return type to their own Type!
- Specified by:
withParallelMarshalling
in classEntityStreamingSupport
- Parameters:
parallelism
- (undocumented)unordered
- (undocumented)- Returns:
- (undocumented)
-
withSupported
public JsonEntityStreamingSupport withSupported(ContentTypeRange range)
Description copied from class:EntityStreamingSupport
Read-side, allows changing what content types are accepted by this framing.EntityStreamingSupport traits MUST support re-configuring the accepted
ContentTypeRange
.This is in order to support a-typical APIs which users still want to communicate with using the provided support trait. Typical examples include APIs which return valid
application/json
however advertise the content type as beingapplication/javascript
or vendor specific content types, which still parse correctly as JSON, CSV or something else that a provided support trait is built for.NOTE: Implementations should specialize the return type to their own Type!
- Specified by:
withSupported
in classEntityStreamingSupport
- Parameters:
range
- (undocumented)- Returns:
- (undocumented)
-
-