public class StreamUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
StreamUtils.CaptureMaterializationAndTerminationOp$ |
static class |
StreamUtils.CaptureTerminationOp$ |
static class |
StreamUtils.DelayCancellationStage<T> |
static interface |
StreamUtils.EntityStreamOp<M> |
static interface |
StreamUtils.OneTimeValve
Similar to Source.maybe but doesn't rely on materialization.
|
static class |
StreamUtils.OneTimeValve$ |
static interface |
StreamUtils.ScheduleSupport |
static class |
StreamUtils.StreamControl |
static class |
StreamUtils.StreamControl$ |
Constructor and Description |
---|
StreamUtils() |
Modifier and Type | Method and Description |
---|---|
static org.apache.pekko.stream.stage.GraphStage<org.apache.pekko.stream.FlowShape<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString>> |
byteStringTransformer(scala.Function1<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString> f,
scala.Function0<org.apache.pekko.util.ByteString> finish)
Creates a transformer that will call
f for each incoming ByteString and output its result. |
static void |
cancelSource(org.apache.pekko.stream.scaladsl.Source<?,?> source,
org.apache.pekko.stream.Materializer materializer)
Tries to guess whether a source needs to cancelled and how.
|
static <T,Mat> scala.Tuple4<org.apache.pekko.stream.scaladsl.Source<T,Mat>,scala.concurrent.Future<scala.runtime.BoxedUnit>,scala.concurrent.Future<scala.runtime.BoxedUnit>,org.apache.pekko.stream.KillSwitch> |
captureMaterializationTerminationAndKillSwitch(org.apache.pekko.stream.scaladsl.Source<T,Mat> source) |
static <T,Mat> scala.Tuple2<org.apache.pekko.stream.scaladsl.Source<T,Mat>,scala.concurrent.Future<scala.runtime.BoxedUnit>> |
captureTermination(org.apache.pekko.stream.scaladsl.Source<T,Mat> source) |
static <T> org.apache.pekko.stream.scaladsl.Flow<T,T,org.apache.pekko.NotUsed> |
delayCancellation(scala.concurrent.duration.Duration cancelAfter)
INTERNAL API
Returns a flow that is almost identity but delays propagation of cancellation from downstream to upstream.
|
static <T> org.apache.pekko.stream.scaladsl.Flow<T,T,org.apache.pekko.NotUsed> |
encodeErrorAndComplete(scala.Function1<java.lang.Throwable,T> f) |
static scala.concurrent.Future<org.apache.pekko.stream.IOResult> |
handleIOResult(org.apache.pekko.stream.IOResult ioResult)
Small helper necessary to deal with errors happening during IO operations like FileIO.toPath.
|
static org.apache.pekko.stream.stage.GraphStage<org.apache.pekko.stream.FlowShape<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString>> |
limitByteChunksStage(int maxBytesPerChunk) |
static org.apache.pekko.stream.Materializer |
OnlyRunInGraphInterpreterContext()
Dummy name to signify that the caller asserts that cancelSource is only run from within a GraphInterpreter context
|
static org.apache.pekko.stream.scaladsl.Flow<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString,org.apache.pekko.NotUsed> |
sliceBytesTransformer(long start,
long length) |
static <T,U> org.apache.pekko.stream.scaladsl.Flow<T,U,org.apache.pekko.NotUsed> |
statefulAttrsMap(scala.Function1<org.apache.pekko.stream.Attributes,scala.Function1<T,U>> functionConstructor)
Lifts the streams attributes into an element and passes them to the function for each passed through element.
|
static <T extends HttpEntity,M> |
transformEntityStream(T entity,
StreamUtils.EntityStreamOp<M> streamOp) |
public static org.apache.pekko.stream.stage.GraphStage<org.apache.pekko.stream.FlowShape<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString>> byteStringTransformer(scala.Function1<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString> f, scala.Function0<org.apache.pekko.util.ByteString> finish)
f
for each incoming ByteString and output its result. After the complete
input has been read it will call finish
once to determine the final ByteString to post to the output.
Empty ByteStrings are discarded.f
- (undocumented)finish
- (undocumented)public static <T,Mat> scala.Tuple2<org.apache.pekko.stream.scaladsl.Source<T,Mat>,scala.concurrent.Future<scala.runtime.BoxedUnit>> captureTermination(org.apache.pekko.stream.scaladsl.Source<T,Mat> source)
public static <T,Mat> scala.Tuple4<org.apache.pekko.stream.scaladsl.Source<T,Mat>,scala.concurrent.Future<scala.runtime.BoxedUnit>,scala.concurrent.Future<scala.runtime.BoxedUnit>,org.apache.pekko.stream.KillSwitch> captureMaterializationTerminationAndKillSwitch(org.apache.pekko.stream.scaladsl.Source<T,Mat> source)
public static org.apache.pekko.stream.scaladsl.Flow<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString,org.apache.pekko.NotUsed> sliceBytesTransformer(long start, long length)
public static org.apache.pekko.stream.stage.GraphStage<org.apache.pekko.stream.FlowShape<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString>> limitByteChunksStage(int maxBytesPerChunk)
public static <T> org.apache.pekko.stream.scaladsl.Flow<T,T,org.apache.pekko.NotUsed> delayCancellation(scala.concurrent.duration.Duration cancelAfter)
Returns a flow that is almost identity but delays propagation of cancellation from downstream to upstream.
cancelAfter
- (undocumented)public static <T,U> org.apache.pekko.stream.scaladsl.Flow<T,U,org.apache.pekko.NotUsed> statefulAttrsMap(scala.Function1<org.apache.pekko.stream.Attributes,scala.Function1<T,U>> functionConstructor)
FlowOps.statefulMapConcat
but for a simple map.
The result of Attributes => (T => U)
is cached, and only the T => U
function will be invoked afterwards for each element.
functionConstructor
- (undocumented)public static org.apache.pekko.stream.Materializer OnlyRunInGraphInterpreterContext()
public static void cancelSource(org.apache.pekko.stream.scaladsl.Source<?,?> source, org.apache.pekko.stream.Materializer materializer)
source
- (undocumented)materializer
- (undocumented)public static <T extends HttpEntity,M> scala.Tuple2<T,M> transformEntityStream(T entity, StreamUtils.EntityStreamOp<M> streamOp)
public static scala.concurrent.Future<org.apache.pekko.stream.IOResult> handleIOResult(org.apache.pekko.stream.IOResult ioResult)
Here we make sure to unnest errors.
Can be removed when https://github.com/akka/akka/issues/23951 is finally fixed.
ioResult
- (undocumented)public static <T> org.apache.pekko.stream.scaladsl.Flow<T,T,org.apache.pekko.NotUsed> encodeErrorAndComplete(scala.Function1<java.lang.Throwable,T> f)