Package org.apache.pekko.http.impl.util
Class StreamUtils
java.lang.Object
org.apache.pekko.http.impl.util.StreamUtils
INTERNAL API
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic final classstatic interfacestatic interfaceSimilar to Source.maybe but doesn't rely on materialization.static classstatic interfacestatic classstatic class
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic 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 callffor each incoming ByteString and output its result.static voidcancelSource(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 APIstatic <T> org.apache.pekko.stream.scaladsl.Flow<T,T, org.apache.pekko.NotUsed> encodeErrorAndComplete(scala.Function1<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.MaterializerDummy name to signify that the caller asserts that cancelSource is only run from within a GraphInterpreter contextstatic 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> 
 scala.Tuple2<T,M> transformEntityStream(T entity, StreamUtils.EntityStreamOp<M> streamOp) 
- 
Constructor Details- 
StreamUtilspublic StreamUtils()
 
- 
- 
Method Details- 
byteStringTransformerpublic 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 callffor each incoming ByteString and output its result. After the complete input has been read it will callfinishonce to determine the final ByteString to post to the output. Empty ByteStrings are discarded.- Parameters:
- f- (undocumented)
- finish- (undocumented)
- Returns:
- (undocumented)
 
- 
captureTerminationpublic static <T,Mat> scala.Tuple2<org.apache.pekko.stream.scaladsl.Source<T,Mat>, captureTerminationscala.concurrent.Future<scala.runtime.BoxedUnit>> (org.apache.pekko.stream.scaladsl.Source<T, Mat> source) 
- 
captureMaterializationTerminationAndKillSwitchpublic static <T,Mat> scala.Tuple4<org.apache.pekko.stream.scaladsl.Source<T,Mat>, captureMaterializationTerminationAndKillSwitchscala.concurrent.Future<scala.runtime.BoxedUnit>, scala.concurrent.Future<scala.runtime.BoxedUnit>, org.apache.pekko.stream.KillSwitch> (org.apache.pekko.stream.scaladsl.Source<T, Mat> source) 
- 
sliceBytesTransformerpublic static org.apache.pekko.stream.scaladsl.Flow<org.apache.pekko.util.ByteString,org.apache.pekko.util.ByteString, sliceBytesTransformerorg.apache.pekko.NotUsed> (long start, long length) 
- 
limitByteChunksStagepublic 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) 
- 
delayCancellationpublic static <T> org.apache.pekko.stream.scaladsl.Flow<T,T, delayCancellationorg.apache.pekko.NotUsed> (scala.concurrent.duration.Duration cancelAfter) INTERNAL APIReturns a flow that is almost identity but delays propagation of cancellation from downstream to upstream. - Parameters:
- cancelAfter- (undocumented)
- Returns:
- (undocumented)
 
- 
statefulAttrsMappublic static <T,U> org.apache.pekko.stream.scaladsl.Flow<T,U, statefulAttrsMaporg.apache.pekko.NotUsed> (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. Similar idea thanFlowOps.statefulMapConcatbut for a simple map.The result of Attributes => (T => U)is cached, and only theT => Ufunction will be invoked afterwards for each element.- Parameters:
- functionConstructor- (undocumented)
- Returns:
- (undocumented)
 
- 
OnlyRunInGraphInterpreterContextpublic 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
- 
cancelSourcepublic 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. In the best case no materialization should be needed.- Parameters:
- source- (undocumented)
- materializer- (undocumented)
 
- 
transformEntityStreampublic static <T extends HttpEntity,M> scala.Tuple2<T,M> transformEntityStream(T entity, StreamUtils.EntityStreamOp<M> streamOp) 
- 
handleIOResultpublic 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. In these operations, a failure during writing data will be turn into a successful IOResult containing a nested failure.Here we make sure to unnest errors. Can be removed when https://github.com/akka/akka/issues/23951 is finally fixed. - Parameters:
- ioResult- (undocumented)
- Returns:
- (undocumented)
 
- 
encodeErrorAndCompletepublic static <T> org.apache.pekko.stream.scaladsl.Flow<T,T, encodeErrorAndCompleteorg.apache.pekko.NotUsed> (scala.Function1<Throwable, T> f) 
 
-