Class Flow<In,Out,Mat>
- All Implemented Interfaces:
Graph<FlowShape<In,,Out>, Mat> FlowOps<Out,,Mat> FlowOpsMat<Out,Mat>
Flow is a set of stream processing steps that has one open input and one open output.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.pekko.stream.Graph
Graph.GraphMapMatVal<S extends Shape,M> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAttributes(Attributes attr) Add the given attributes to thisFlow.apply()Returns aFlowwhich outputs all its inputs.<U,CtxU, CtxOut>
FlowWithContext<U,CtxU, Out, CtxOut, Mat> asFlowWithContext(scala.Function2<U, CtxU, In> collapseContext, scala.Function1<Out, CtxOut> extractContext) Turns a Flow into a FlowWithContext which manages a context per element along a stream.asJava()Converts this Scala DSL element to it's Java DSL counterpart.async()Put an asynchronous boundary around thisFlowPut an asynchronous boundary around thisFlowPut an asynchronous boundary around thisFlowTransform this Flow by applying a function to each *incoming* upstream element before it is passed to theFlowTransform this Flow by applying a functionfto each *incoming* upstream element before it is passed to theFlow, and a functiongto each *outgoing* downstream element.fromFunction(scala.Function1<A, B> f) Creates a [Flow] which will use the given function to transform its inputs to outputs.static <I,O, M> Flow<I, O, M> A graph with the shape of a flow logically is a flow, this method makes it so also in type.static <T,U, M> Flow<T, U, scala.concurrent.Future<M>> fromMaterializer(scala.Function2<Materializer, Attributes, Flow<T, U, M>> factory) Defers the creation of aFlowuntil materialization.fromProcessor(scala.Function0<org.reactivestreams.Processor<I, O>> processorFactory) Creates a Flow from a Reactive StreamsProcessorstatic <I,O, M> Flow<I, O, M> fromProcessorMat(scala.Function0<scala.Tuple2<org.reactivestreams.Processor<I, O>, M>> processorFactory) Creates a Flow from a Reactive StreamsProcessorand returns a materialized value.fromSinkAndSource(Graph<SinkShape<I>, ?> sink, Graph<SourceShape<O>, ?> source) Creates aFlowfrom aSinkand aSourcewhere the Flow's input will be sent to the Sink and the Flow's output will come from the Source.fromSinkAndSourceCoupled(Graph<SinkShape<I>, ?> sink, Graph<SourceShape<O>, ?> source) Allows coupling termination (cancellation, completion, erroring) of Sinks and Sources while creating a Flow from them.static <I,O, M1, M2, M>
Flow<I,O, M> fromSinkAndSourceCoupledMat(Graph<SinkShape<I>, M1> sink, Graph<SourceShape<O>, M2> source, scala.Function2<M1, M2, M> combine) Allows coupling termination (cancellation, completion, erroring) of Sinks and Sources while creating a Flow from them.static <I,O, M1, M2, M>
Flow<I,O, M> fromSinkAndSourceMat(Graph<SinkShape<I>, M1> sink, Graph<SourceShape<O>, M2> source, scala.Function2<M1, M2, M> combine) Creates aFlowfrom aSinkand aSourcewhere the Flow's input will be sent to the Sink and the Flow's output will come from the Source.static <I,O, M> Flow<I, O, scala.concurrent.Future<M>> futureFlow(scala.concurrent.Future<Flow<I, O, M>> flow) Turn aFuture[Flow]into a flow that will consume the values of the source when the future completes successfully.<Mat2> RunnableGraph<Mat>Join thisFlowto anotherFlow, by cross connecting the inputs and outputs, creating aRunnableGraph.<I2,O1, Mat2, M>
Flow<I2,O1, M> <Mat2,Mat3>
RunnableGraph<Mat3>Join thisFlowto anotherFlow, by cross connecting the inputs and outputs, creating aRunnableGraphstatic <I,O, M> Flow<I, O, scala.concurrent.Future<M>> Defers invoking thecreatefunction to create a future flow until there is downstream demand and passing that downstream demand upstream triggers the first element.static <I,O, M> Flow<I, O, scala.concurrent.Future<M>> lazyFutureFlow(scala.Function0<scala.concurrent.Future<Flow<I, O, M>>> create) Defers invoking thecreatefunction to create a future flow until there downstream demand has caused upstream to send a first element.mapMaterializedValue(scala.Function1<Mat, Mat2> f) Transform the materialized value of this Flow, leaving all other properties as they were.materializeIntoSource(Graph<SourceShape<In>, Mat1> source, Graph<SinkShape<Out>, scala.concurrent.Future<Mat2>> sink) Add anameattribute to this Flow.static <FIn,FOut, FViaOut, FMat, FViaMat, Mat>
Flow<FIn,scala.Option<FViaOut>, Mat> optionalVia(Flow<FIn, scala.Option<FOut>, FMat> flow, Flow<FOut, FViaOut, FViaMat> viaFlow, scala.Function2<FMat, FViaMat, Mat> combine) Creates a FlowW from an existing base Flow outputting an optional element and applying an additional viaFlow only if the element in the stream is defined.preMaterialize(Materializer materializer) <Mat1,Mat2>
scala.Tuple2<Mat1,Mat2> runWith(Graph<SourceShape<In>, Mat1> source, Graph<SinkShape<Out>, Mat2> sink, Materializer materializer) Connect theSourceto thisFlowand then connect it to theSinkand run it.shape()The shape of a graph is all that is externally visible: its inlets and outlets.RunnableGraph<org.reactivestreams.Processor<In,Out>> Converts this Flow to aRunnableGraphthat materializes to a Reactive StreamsProcessorwhich implements the operations encapsulated by this Flow.toString()org.apache.pekko.stream.impl.LinearTraversalBuilderINTERNAL API.Transform thisFlowby appending the given processing steps.withAttributes(Attributes attr) Replace the attributes of thisFlowwith the given ones.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.pekko.stream.scaladsl.FlowOps
$plus$plus, aggregateWithBoundary, alsoTo, alsoToAll, alsoToGraph, ask, ask, backpressureTimeout, batch, batchWeighted, buffer, collect, collectFirst, collectType, collectWhile, completionTimeout, concat, concatAllLazy, concatGraph, concatLazy, conflate, conflateWithSeed, delay, delay$default$2, delayWith, detach, divertTo, divertToGraph, doOnCancel, doOnFirst, drop, dropRepeated, dropRepeated, dropWhile, dropWithin, expand, extrapolate, extrapolate$default$2, filter, filterNot, flatMap, flatMapConcat, flatMapConcat, flatMapMerge, flatMapPrefix, flatten, flattenMerge, fold, foldAsync, foldWhile, groupBy, groupBy, grouped, groupedAdjacentBy, groupedAdjacentByWeighted, groupedWeighted, groupedWeightedWithin, groupedWeightedWithin, groupedWithin, idleTimeout, initialDelay, initialTimeout, interleave, interleave, interleaveAll, interleaveGraph, interleaveGraph$default$3, internalConcat, internalConcatAll, intersperse, intersperse, keepAlive, limit, limitWeighted, log, log$default$2, log$default$3, logWithMarker, logWithMarker$default$3, logWithMarker$default$4, map, mapAsync, mapAsyncPartitioned, mapAsyncPartitionedUnordered, mapAsyncUnordered, mapConcat, mapError, mapOption, mapWithResource, mapWithResource, merge, merge$default$2, mergeAll, mergeGraph, mergeLatest, mergeLatest$default$2, mergeLatestGraph, mergePreferred, mergePreferred$default$3, mergePreferredGraph, mergePrioritized, mergePrioritized$default$4, mergePrioritizedGraph, mergeSorted, mergeSortedGraph, onErrorComplete, onErrorComplete, onErrorContinue, onErrorContinue, orElse, orElseGraph, prefixAndTail, prepend, prependGraph, prependLazy, recover, recoverWith, recoverWithRetries, reduce, scan, scanAsync, sliding, sliding$default$2, splitAfter, splitAfter, splitWhen, splitWhen, statefulMap, statefulMapConcat, switchMap, take, takeUntil, takeWhile, takeWhile, takeWithin, throttle, throttle, throttle, throttle, watch, wireTap, wireTap, wireTapGraph, withFilter, zip, zipAll, zipAllFlow, zipGraph, zipLatest, zipLatestGraph, zipLatestWith, zipLatestWith, zipLatestWithGraph, zipLatestWithGraph, zipWith, zipWithGraph, zipWithIndexMethods inherited from interface org.apache.pekko.stream.scaladsl.FlowOpsMat
alsoToMat, concatLazyMat, concatMat, divertToMat, flatMapPrefixMat, foreach, interleaveMat, interleaveMat, mergeLatestMat, mergeMat, mergeMat$default$2, mergePreferredMat, mergePrioritizedMat, mergeSortedMat, monitor, monitorMat, orElseMat, prependLazyMat, prependMat, watchTermination, wireTapMat, zipAllMat, zipLatestMat, zipLatestWithMat, zipLatestWithMat, zipMat, zipWithMatMethods inherited from interface org.apache.pekko.stream.Graph
getAttributes
-
Constructor Details
-
Flow
-
-
Method Details
-
fromProcessor
public static <I,O> Flow<I,O, fromProcessorNotUsed> (scala.Function0<org.reactivestreams.Processor<I, O>> processorFactory) Creates a Flow from a Reactive StreamsProcessor -
fromProcessorMat
public static <I,O, Flow<I,M> O, fromProcessorMatM> (scala.Function0<scala.Tuple2<org.reactivestreams.Processor<I, O>, M>> processorFactory) Creates a Flow from a Reactive StreamsProcessorand returns a materialized value. -
apply
Returns aFlowwhich outputs all its inputs. -
fromFunction
Creates a [Flow] which will use the given function to transform its inputs to outputs. It is equivalent toFlow[T].map(f) -
optionalVia
public static <FIn,FOut, Flow<FIn,FViaOut, FMat, FViaMat, Mat> scala.Option<FViaOut>, optionalViaMat> (Flow<FIn, scala.Option<FOut>, FMat> flow, Flow<FOut, FViaOut, FViaMat> viaFlow, scala.Function2<FMat, FViaMat, Mat> combine) Creates a FlowW from an existing base Flow outputting an optional element and applying an additional viaFlow only if the element in the stream is defined.'''Emits when''' the provided viaFlow runs with defined elements
'''Backpressures when''' the viaFlow runs for the defined elements and downstream backpressures
'''Completes when''' upstream completes
'''Cancels when''' downstream cancels
- Parameters:
flow- The base flow that outputs an optional elementviaFlow- The flow that gets used if the optional element in is defined.combine- How to combine the materialized values of flow and viaFlow- Returns:
- a Flow with the viaFlow applied onto defined elements of the flow. The output value is contained within an Option which indicates whether the original flow's element had viaFlow applied.
- Since:
- 1.1.0
-
fromGraph
A graph with the shape of a flow logically is a flow, this method makes it so also in type. -
fromMaterializer
public static <T,U, Flow<T,M> U, fromMaterializerscala.concurrent.Future<M>> (scala.Function2<Materializer, Attributes, Flow<T, U, M>> factory) -
fromSinkAndSource
public static <I,O> Flow<I,O, fromSinkAndSourceNotUsed> (Graph<SinkShape<I>, ?> sink, Graph<SourceShape<O>, ?> source) Creates aFlowfrom aSinkand aSourcewhere the Flow's input will be sent to the Sink and the Flow's output will come from the Source.The resulting flow can be visualized as:
+----------------------------------------------+ | Resulting Flow[I, O, NotUsed] | | | | +---------+ +-----------+ | | | | | | | I ~~> | Sink[I] | [no-connection!] | Source[O] | ~~> O | | | | | | | +---------+ +-----------+ | +----------------------------------------------+The completion of the Sink and Source sides of a Flow constructed using this method are independent. So if the Sink receives a completion signal, the Source side will remain unaware of that. If you are looking to couple the termination signals of the two sides use
Flow.fromSinkAndSourceCoupledinstead.See also
<I,O,M1,M2,M>fromSinkAndSourceMat(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<I>,M1>,org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<O>,M2>,scala.Function2<M1,M2,M>)when access to materialized values of the parameters is needed. -
fromSinkAndSourceMat
public static <I,O, Flow<I,M1, M2, M> O, fromSinkAndSourceMatM> (Graph<SinkShape<I>, M1> sink, Graph<SourceShape<O>, M2> source, scala.Function2<M1, M2, M> combine) Creates aFlowfrom aSinkand aSourcewhere the Flow's input will be sent to the Sink and the Flow's output will come from the Source.The resulting flow can be visualized as:
+-------------------------------------------------------+ | Resulting Flow[I, O, M] | | | | +-------------+ +---------------+ | | | | | | | I ~~> | Sink[I, M1] | [no-connection!] | Source[O, M2] | ~~> O | | | | | | | +-------------+ +---------------+ | +------------------------------------------------------+The completion of the Sink and Source sides of a Flow constructed using this method are independent. So if the Sink receives a completion signal, the Source side will remain unaware of that. If you are looking to couple the termination signals of the two sides use
Flow.fromSinkAndSourceCoupledMatinstead.The
combinefunction is used to compose the materialized values of thesinkandsourceinto the materialized value of the resultingFlow. -
fromSinkAndSourceCoupled
public static <I,O> Flow<I,O, fromSinkAndSourceCoupledNotUsed> (Graph<SinkShape<I>, ?> sink, Graph<SourceShape<O>, ?> source) Allows coupling termination (cancellation, completion, erroring) of Sinks and Sources while creating a Flow from them. Similar toFlow.fromSinkAndSourcehowever couples the termination of these two operators.The resulting flow can be visualized as:
+---------------------------------------------+ | Resulting Flow[I, O, NotUsed] | | | | +---------+ +-----------+ | | | | | | | I ~~> | Sink[I] | ~~~(coupled)~~~ | Source[O] | ~~> O | | | | | | | +---------+ +-----------+ | +---------------------------------------------+E.g. if the emitted
Flowgets a cancellation, theSourceof course is cancelled, however the Sink will also be completed. The table below illustrates the effects in detail:Returned Flow Sink ( in)Source ( out)cause: upstream (sink-side) receives completion effect: receives completion effect: receives cancel cause: upstream (sink-side) receives error effect: receives error effect: receives cancel cause: downstream (source-side) receives cancel effect: completes effect: receives cancel effect: cancels upstream, completes downstream effect: completes cause: signals complete effect: cancels upstream, errors downstream effect: receives error cause: signals error or throws effect: cancels upstream, completes downstream cause: cancels effect: receives cancel See also
<I,O,M1,M2,M>fromSinkAndSourceCoupledMat(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<I>,M1>,org.apache.pekko.stream.Graph<org.apache.pekko.stream.SourceShape<O>,M2>,scala.Function2<M1,M2,M>)when access to materialized values of the parameters is needed. -
fromSinkAndSourceCoupledMat
public static <I,O, Flow<I,M1, M2, M> O, fromSinkAndSourceCoupledMatM> (Graph<SinkShape<I>, M1> sink, Graph<SourceShape<O>, M2> source, scala.Function2<M1, M2, M> combine) Allows coupling termination (cancellation, completion, erroring) of Sinks and Sources while creating a Flow from them. Similar toFlow.fromSinkAndSourcehowever couples the termination of these two operators.The resulting flow can be visualized as:
+-----------------------------------------------------+ | Resulting Flow[I, O, M] | | | | +-------------+ +---------------+ | | | | | | | I ~~> | Sink[I, M1] | ~~~(coupled)~~~ | Source[O, M2] | ~~> O | | | | | | | +-------------+ +---------------+ | +-----------------------------------------------------+E.g. if the emitted
Flowgets a cancellation, theSourceof course is cancelled, however the Sink will also be completed. The table onFlow.fromSinkAndSourceCoupledillustrates the effects in detail.The
combinefunction is used to compose the materialized values of thesinkandsourceinto the materialized value of the resultingFlow. -
futureFlow
public static <I,O, Flow<I,M> O, futureFlowscala.concurrent.Future<M>> (scala.concurrent.Future<Flow<I, O, M>> flow) Turn aFuture[Flow]into a flow that will consume the values of the source when the future completes successfully. If theFutureis completed with a failure the stream is failed.The materialized future value is completed with the materialized value of the future flow or failed with a
NeverMaterializedExceptionif upstream fails or downstream cancels before the future has completed.The operator's default behavior in case of downstream cancellation before nested flow materialization (future completion) is to cancel immediately. This behavior can be controlled by setting the
pekko.stream.Attributes.NestedMaterializationCancellationPolicy.PropagateToNestedattribute, this will delay downstream cancellation until nested flow's materialization which is then immediately cancelled (with the original cancellation cause). -
lazyFlow
public static <I,O, Flow<I,M> O, lazyFlowscala.concurrent.Future<M>> (scala.Function0<Flow<I, O, M>> create) Defers invoking thecreatefunction to create a future flow until there is downstream demand and passing that downstream demand upstream triggers the first element.The materialized future value is completed with the materialized value of the created flow when that has successfully been materialized.
If the
createfunction throws or returns a future that fails the stream is failed, in this case the materialized future value is failed with aNeverMaterializedException.Note that asynchronous boundaries (and other operators) in the stream may do pre-fetching which counter acts the laziness and can trigger the factory earlier than expected.
'''Emits when''' the internal flow is successfully created and it emits
'''Backpressures when''' the internal flow is successfully created and it backpressures or downstream backpressures
'''Completes when''' upstream completes and all elements have been emitted from the internal flow
'''Cancels when''' downstream cancels (see below)
The operator's default behavior in case of downstream cancellation before nested flow materialization (future completion) is to cancel immediately. This behavior can be controlled by setting the
pekko.stream.Attributes.NestedMaterializationCancellationPolicy.PropagateToNestedattribute, this will delay downstream cancellation until nested flow's materialization which is then immediately cancelled (with the original cancellation cause). -
lazyFutureFlow
public static <I,O, Flow<I,M> O, lazyFutureFlowscala.concurrent.Future<M>> (scala.Function0<scala.concurrent.Future<Flow<I, O, M>>> create) Defers invoking thecreatefunction to create a future flow until there downstream demand has caused upstream to send a first element.The materialized future value is completed with the materialized value of the created flow when that has successfully been materialized.
If the
createfunction throws or returns a future that fails the stream is failed, in this case the materialized future value is failed with aNeverMaterializedException.Note that asynchronous boundaries (and other operators) in the stream may do pre-fetching which counter acts the laziness and can trigger the factory earlier than expected.
'''Emits when''' the internal flow is successfully created and it emits
'''Backpressures when''' the internal flow is successfully created and it backpressures or downstream backpressures
'''Completes when''' upstream completes and all elements have been emitted from the internal flow
'''Cancels when''' downstream cancels (see below)
The operator's default behavior in case of downstream cancellation before nested flow materialization (future completion) is to cancel immediately. This behavior can be controlled by setting the
pekko.stream.Attributes.NestedMaterializationCancellationPolicy.PropagateToNestedattribute, this will delay downstream cancellation until nested flow's materialization which is then immediately cancelled (with the original cancellation cause). -
traversalBuilder
public org.apache.pekko.stream.impl.LinearTraversalBuilder traversalBuilder()Description copied from interface:GraphINTERNAL API.Every materializable element must be backed by a stream layout module
- Specified by:
traversalBuilderin interfaceGraph<In,Out>
-
shape
Description copied from interface:GraphThe shape of a graph is all that is externally visible: its inlets and outlets. -
toString
-
via
-
viaMat
public <T,Mat2, Flow<In,Mat3> T, viaMatMat3> (Graph<FlowShape<Out, T>, Mat2> flow, scala.Function2<Mat, Mat2, Mat3> combine) Description copied from interface:FlowOpsMatTransform thisFlowby appending the given processing steps.
The+---------------------------------+ | Resulting Flow[In, T, M2] | | | | +------+ +------+ | | | | | | | In ~~> | this | ~~Out~~> | flow | ~~> T | | Mat| | M| | | +------+ +------+ | +---------------------------------+combinefunction is used to compose the materialized values of this flow and that flow into the materialized value of the resulting Flow.It is recommended to use the internally optimized
Keep.leftandKeep.rightcombiners where appropriate instead of manually writing functions that pass through one of the values.- Specified by:
viaMatin interfaceFlowOpsMat<In,Out>
-
to
Connect thisFlowto aSink, concatenating the processing steps of both.
The materialized value of the combined+------------------------------+ | Resulting Sink[In, Mat] | | | | +------+ +------+ | | | | | | | In ~~> | flow | ~~Out~~> | sink | | | | Mat| | M| | | +------+ +------+ | +------------------------------+Sinkwill be the materialized value of the current flow (ignoring the given Sink’s value), use {@link Flow#toMat[Mat2* toMat} if a different strategy is needed.See also
<Mat2,Mat3>toMat(org.apache.pekko.stream.Graph<org.apache.pekko.stream.SinkShape<Out>,Mat2>,scala.Function2<Mat,Mat2,Mat3>)when access to materialized values of the parameter is needed. -
toMat
public <Mat2,Mat3> Sink<In,Mat3> toMat(Graph<SinkShape<Out>, Mat2> sink, scala.Function2<Mat, Mat2, Mat3> combine) Connect thisFlowto aSink, concatenating the processing steps of both.
The+----------------------------+ | Resulting Sink[In, M2] | | | | +------+ +------+ | | | | | | | In ~~> | flow | ~Out~> | sink | | | | Mat| | M| | | +------+ +------+ | +----------------------------+combinefunction is used to compose the materialized values of this flow and that Sink into the materialized value of the resulting Sink.It is recommended to use the internally optimized
Keep.leftandKeep.rightcombiners where appropriate instead of manually writing functions that pass through one of the values.- Specified by:
toMatin interfaceFlowOpsMat<In,Out>
-
mapMaterializedValue
Transform the materialized value of this Flow, leaving all other properties as they were.- Specified by:
mapMaterializedValuein interfaceFlowOpsMat<In,Out>
-
preMaterialize
-
materializeIntoSource
public <Mat1,Mat2> Source<Mat2,scala.concurrent.Future<NotUsed>> materializeIntoSource(Graph<SourceShape<In>, Mat1> source, Graph<SinkShape<Out>, scala.concurrent.Future<Mat2>> sink) Connects theSourceto thisFlowand materializes it using theSink, immediately returning the values via the providedSinkas a newSource.- Parameters:
source- A source that connects to this flowsink- A sink which needs to materialize into aFuture, typically one that collects values such asSink.headorSink.seq- Returns:
- A new
Sourcethat contains the results of theFlowwith the providedSource's elements run with theSink - Since:
- 1.2.0
-
contramap
Transform this Flow by applying a function to each *incoming* upstream element before it is passed to theFlow'''Backpressures when''' original
Flowbackpressures'''Cancels when''' original
Flowcancels- Since:
- 1.1.0
-
dimap
Transform this Flow by applying a functionfto each *incoming* upstream element before it is passed to theFlow, and a functiongto each *outgoing* downstream element.'''Emits when''' the mapping function
greturns an element'''Backpressures when''' original
Flowbackpressures'''Completes when''' original
Flowcompletes'''Cancels when''' original
Flowcancels- Since:
- 1.1.0
-
join
Join thisFlowto anotherFlow, by cross connecting the inputs and outputs, creating aRunnableGraph.
The materialized value of the combined+------+ +-------+ | | ~Out~> | | | this | | other | | | <~In~ | | +------+ +-------+Flowwill be the materialized value of the current flow (ignoring the other Flow’s value), use {@link Flow#joinMat[Mat2* joinMat} if a different strategy is needed. -
joinMat
public <Mat2,Mat3> RunnableGraph<Mat3> joinMat(Graph<FlowShape<Out, In>, Mat2> flow, scala.Function2<Mat, Mat2, Mat3> combine) Join thisFlowto anotherFlow, by cross connecting the inputs and outputs, creating aRunnableGraph
The+------+ +-------+ | | ~Out~> | | | this | | other | | | <~In~ | | +------+ +-------+combinefunction is used to compose the materialized values of this flow and that Flow into the materialized value of the resulting Flow.It is recommended to use the internally optimized
Keep.leftandKeep.rightcombiners where appropriate instead of manually writing functions that pass through one of the values. -
join
Join thisFlowto aBidiFlowto close off the “top” of the protocol stack:
The materialized value of the combined+---------------------------+ | Resulting Flow | | | | +------+ +------+ | | | | ~Out~> | | ~~> O1 | | flow | | bidi | | | | | <~In~ | | <~~ I2 | +------+ +------+ | +---------------------------+Flowwill be the materialized value of the current flow (ignoring theBidiFlow’s value), use {@link Flow#joinMat[I2* joinMat} if a different strategy is needed. -
joinMat
public <I2,O1, Flow<I2,Mat2, M> O1, joinMatM> (Graph<BidiShape<Out, O1, I2, In>, Mat2> bidi, scala.Function2<Mat, Mat2, M> combine) Join thisFlowto aBidiFlowto close off the “top” of the protocol stack:
The+---------------------------+ | Resulting Flow | | | | +------+ +------+ | | | | ~Out~> | | ~~> O1 | | flow | | bidi | | | | | <~In~ | | <~~ I2 | +------+ +------+ | +---------------------------+combinefunction is used to compose the materialized values of this flow and thatBidiFlowinto the materialized value of the resultingFlow.It is recommended to use the internally optimized
Keep.leftandKeep.rightcombiners where appropriate instead of manually writing functions that pass through one of the values. -
withAttributes
Replace the attributes of thisFlowwith the given ones. If this Flow is a composite of multiple graphs, new attributes on the composite will be less specific than attributes set directly on the individual graphs of the composite.Note that this operation has no effect on an empty Flow (because the attributes apply only to the contained processing operators).
- Specified by:
withAttributesin interfaceFlowOps<In,Out> - Specified by:
withAttributesin interfaceGraph<In,Out>
-
addAttributes
Add the given attributes to thisFlow. If the specific attribute was already present on this graph this means the added attribute will be more specific than the existing one. If this Flow is a composite of multiple graphs, new attributes on the composite will be less specific than attributes set directly on the individual graphs of the composite.- Specified by:
addAttributesin interfaceFlowOps<In,Out> - Specified by:
addAttributesin interfaceGraph<In,Out>
-
named
Add anameattribute to this Flow. -
async
Put an asynchronous boundary around thisFlow -
async
Put an asynchronous boundary around thisFlow -
async
Put an asynchronous boundary around thisFlow -
runWith
public <Mat1,Mat2> scala.Tuple2<Mat1,Mat2> runWith(Graph<SourceShape<In>, Mat1> source, Graph<SinkShape<Out>, Mat2> sink, Materializer materializer) Connect theSourceto thisFlowand then connect it to theSinkand run it. The returned tuple contains the materialized values of theSourceandSink, e.g. theSubscriberof a of aSource#subscriberand andPublisherof aSink#publisher.Note that the
ActorSystemcan be used as the implicitmaterializerparameter to use thepekko.stream.SystemMaterializerfor running the stream. -
toProcessor
Converts this Flow to aRunnableGraphthat materializes to a Reactive StreamsProcessorwhich implements the operations encapsulated by this Flow. Every materialization results in a new Processor instance, i.e. the returnedRunnableGraphis reusable.- Returns:
- A
RunnableGraphthat materializes to a Processor when run() is called on it.
-
asFlowWithContext
public <U,CtxU, FlowWithContext<U,CtxOut> CtxU, asFlowWithContextOut, CtxOut, Mat> (scala.Function2<U, CtxU, In> collapseContext, scala.Function1<Out, CtxOut> extractContext) Turns a Flow into a FlowWithContext which manages a context per element along a stream.- Parameters:
collapseContext- turn each incoming pair of element and context value into an element of this FlowextractContext- turn each outgoing element of this Flow into an outgoing context value
-
asJava
Converts this Scala DSL element to it's Java DSL counterpart.
-