Package org.apache.pekko.stream.javadsl
Class BidiFlow<I1,O1,I2,O2,Mat>
java.lang.Object
org.apache.pekko.stream.javadsl.BidiFlow<I1,O1,I2,O2,Mat>
-
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 this Source.asScala()
async()
Put an asynchronous boundary around thisFlow
Put an asynchronous boundary around thisFlow
Put an asynchronous boundary around thisFlow
Add the given BidiFlow as the next step in a bidirectional transformation pipeline.Add the given BidiFlow as the next step in a bidirectional transformation 161bidirectionalIdleTimeout
(Duration timeout) If the time between two processed elements *in any direction* exceed the provided timeout, the stream is failed with aBackpressureTimeoutException
.Wraps two Flows to create a ''BidiFlow''.static <I1,
O1, I2, O2, M1, M2, M>
BidiFlow<I1,O1, I2, O2, M> fromFlowsMat
(Graph<FlowShape<I1, O1>, M1> flow1, Graph<FlowShape<I2, O2>, M2> flow2, Function2<M1, M2, M> combine) Wraps two Flows to create a ''BidiFlow''.fromFunctions
(Function<I1, O1> top, Function<I2, O2> bottom) Create a BidiFlow where the top and bottom flows are just one simple mapping operator each, expressed by the two functions.static <I1,
O1, I2, O2, M>
BidiFlow<I1,O1, I2, O2, M> A graph with the shape of a BidiFlow logically is a BidiFlow, this method makes it so also in type.identity()
Add the given Flow as the final step in a bidirectional transformation pipeline.Add the given Flow as the final step in a bidirectional transformation pipeline.mapMaterializedValue
(Function<Mat, Mat2> f) Transform only the materialized value of this BidiFlow, leaving all other properties as they were.Add aname
attribute to this Flow.
reversed()
Turn this BidiFlow around by 180 degrees, logically flipping it upside down in a protocol stack.shape()
The shape of a graph is all that is externally visible: its inlets and outlets.org.apache.pekko.stream.impl.TraversalBuilder
INTERNAL API.withAttributes
(Attributes attr) Change the attributes of thisSource
to the given ones and seal the list of attributes.
-
Constructor Details
-
BidiFlow
-
-
Method Details
-
identity
-
fromGraph
public static <I1,O1, BidiFlow<I1,I2, O2, M> O1, fromGraphI2, O2, M> (Graph<BidiShape<I1, O1, I2, O2>, M> g) A graph with the shape of a BidiFlow logically is a BidiFlow, this method makes it so also in type. -
fromFlowsMat
public static <I1,O1, BidiFlow<I1,I2, O2, M1, M2, M> O1, fromFlowsMatI2, O2, M> (Graph<FlowShape<I1, O1>, M1> flow1, Graph<FlowShape<I2, O2>, M2> flow2, Function2<M1, M2, M> combine) Wraps two Flows to create a ''BidiFlow''. The materialized value of the resulting BidiFlow is determined by the combiner function passed in the second argument list.+----------------------------+ | Resulting BidiFlow | | | | +----------------------+ | I1 ~~> | Flow1 | ~~> O1 | +----------------------+ | | | | +----------------------+ | O2 <~~ | Flow2 | <~~ I2 | +----------------------+ | +----------------------------+
-
fromFlows
public static <I1,O1, BidiFlow<I1,I2, O2, M1, M2> O1, fromFlowsI2, O2, NotUsed> (Graph<FlowShape<I1, O1>, M1> flow1, Graph<FlowShape<I2, O2>, M2> flow2) Wraps two Flows to create a ''BidiFlow''. The materialized value of the resulting BidiFlow is NotUsed.+----------------------------+ | Resulting BidiFlow | | | | +----------------------+ | I1 ~~> | Flow1 | ~~> O1 | +----------------------+ | | | | +----------------------+ | O2 <~~ | Flow2 | <~~ I2 | +----------------------+ | +----------------------------+
-
fromFunctions
public static <I1,O1, BidiFlow<I1,I2, O2> O1, fromFunctionsI2, O2, NotUsed> (Function<I1, O1> top, Function<I2, O2> bottom) Create a BidiFlow where the top and bottom flows are just one simple mapping operator each, expressed by the two functions. -
bidirectionalIdleTimeout
If the time between two processed elements *in any direction* exceed the provided timeout, the stream is failed with aBackpressureTimeoutException
.There is a difference between this operator and having two idleTimeout Flows assembled into a BidiStage. If the timeout is configured to be 1 seconds, then this operator will not fail even though there are elements flowing every second in one direction, but no elements are flowing in the other direction. I.e. this operator considers the *joint* frequencies of the elements in both directions.
-
traversalBuilder
public org.apache.pekko.stream.impl.TraversalBuilder traversalBuilder()Description copied from interface:Graph
INTERNAL API.Every materializable element must be backed by a stream layout module
- Specified by:
traversalBuilder
in interfaceGraph<I1,
O1>
-
shape
Description copied from interface:Graph
The shape of a graph is all that is externally visible: its inlets and outlets. -
asScala
-
atop
Add the given BidiFlow as the next step in a bidirectional transformation pipeline. By convention protocol stacks are growing to the left: the right most is the bottom layer, the closest to the metal.
The materialized value of the combined+----------------------------+ | Resulting BidiFlow | | | | +------+ +------+ | I1 ~~> | | ~O1~> | | ~~> OO1 | | this | | bidi | | O2 <~~ | | <~I2~ | | <~~ II2 | +------+ +------+ | +----------------------------+
BidiFlow
will be the materialized value of the current flow (ignoring the other BidiFlow’s value), useatopMat
if a different strategy is needed. -
atop
public <OO1,II2, BidiFlow<I1,Mat2, M> OO1, atopII2, O2, M> (BidiFlow<O1, OO1, II2, I2, Mat2> bidi, Function2<Mat, Mat2, M> combine) Add the given BidiFlow as the next step in a bidirectional transformation 161pipeline. By convention protocol stacks are growing to the left: the right most is the bottom layer, the closest to the metal.
The+----------------------------+ | Resulting BidiFlow | | | | +------+ +------+ | I1 ~~> | | ~O1~> | | ~~> OO1 | | this | | bidi | | O2 <~~ | | <~I2~ | | <~~ II2 | +------+ +------+ | +----------------------------+
combine
function is used to compose the materialized values of this flow and that flow into the materialized value of the resulting BidiFlow. -
join
Add the given Flow as the final step in a bidirectional transformation pipeline. By convention protocol stacks are growing to the left: the right most is the bottom layer, the closest to the metal.
The materialized value of the combined+---------------------------+ | Resulting Flow | | | | +------+ +------+ | I1 ~~> | | ~O1~> | | | | | this | | flow | | O2 <~~ | | <~I2~ | | | | +------+ +------+ | +---------------------------+
Flow
will be the materialized value of the current flow (ignoring the other Flow’s value), usejoinMat
if a different strategy is needed. -
join
Add the given Flow as the final step in a bidirectional transformation pipeline. By convention protocol stacks are growing to the left: the right most is the bottom layer, the closest to the metal.
The+---------------------------+ | Resulting Flow | | | | +------+ +------+ | I1 ~~> | | ~O1~> | | | | | this | | flow | | O2 <~~ | | <~I2~ | | | | +------+ +------+ | +---------------------------+
combine
function is used to compose the materialized values of this flow and that flow into the materialized value of the resultingFlow
. -
reversed
Turn this BidiFlow around by 180 degrees, logically flipping it upside down in a protocol stack. -
mapMaterializedValue
Transform only the materialized value of this BidiFlow, leaving all other properties as they were. -
withAttributes
Change the attributes of thisSource
to the given ones and seal the list of attributes. This means that further calls will not be able to remove these attributes, but instead add new ones. Note that this operation has no effect on an empty Flow (because the attributes apply only to the contained processing operators).- Specified by:
withAttributes
in interfaceGraph<I1,
O1>
-
addAttributes
Add the given attributes to this Source. Further calls towithAttributes
will not remove these attributes. Note that this operation has no effect on an empty Flow (because the attributes apply only to the contained processing operators).- Specified by:
addAttributes
in interfaceGraph<I1,
O1>
-
named
Add aname
attribute to this Flow.
-
async
Put an asynchronous boundary around thisFlow
-
async
Put an asynchronous boundary around thisFlow
-
async
Put an asynchronous boundary around thisFlow
-
getAttributes
- Specified by:
getAttributes
in interfaceGraph<I1,
O1>
-