Class BidiFlow<I1,​O1,​I2,​O2,​Mat>

  • All Implemented Interfaces:
    Graph<BidiShape<I1,​O1,​I2,​O2>,​Mat>

    public final class BidiFlow<I1,​O1,​I2,​O2,​Mat>
    extends java.lang.Object
    implements Graph<BidiShape<I1,​O1,​I2,​O2>,​Mat>
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BidiFlow<I1,​O1,​I2,​O2,​Mat> addAttributes​(Attributes attr)
      Add the given attributes to this Source.
      <JI1 extends I1,​JO1,​JI2 extends I2,​JO2,​JMat>
      BidiFlow<JI1,​JO1,​JI2,​JO2,​JMat>
      asJava()  
      BidiFlow<I1,​O1,​I2,​O2,​Mat> async()
      Put an asynchronous boundary around this BidiFlow
      BidiFlow<I1,​O1,​I2,​O2,​Mat> async​(java.lang.String dispatcher)
      Put an asynchronous boundary around this BidiFlow
      BidiFlow<I1,​O1,​I2,​O2,​Mat> async​(java.lang.String dispatcher, int inputBufferSize)
      Put an asynchronous boundary around this BidiFlow
      <OO1,​II2,​Mat2>
      BidiFlow<I1,​OO1,​II2,​O2,​Mat>
      atop​(Graph<BidiShape<O1,​OO1,​II2,​I2>,​Mat2> bidi)
      Add the given BidiFlow as the next step in a bidirectional transformation pipeline.
      <OO1,​II2,​Mat2,​M>
      BidiFlow<I1,​OO1,​II2,​O2,​M>
      atopMat​(Graph<BidiShape<O1,​OO1,​II2,​I2>,​Mat2> bidi, scala.Function2<Mat,​Mat2,​M> combine)
      Add the given BidiFlow as the next step in a bidirectional transformation pipeline.
      static <I,​O>
      BidiFlow<I,​I,​O,​O,​NotUsed>
      bidirectionalIdleTimeout​(scala.concurrent.duration.FiniteDuration timeout)
      If the time between two processed elements *in any direction* exceed the provided timeout, the stream is failed with a scala.concurrent.TimeoutException.
      static <I1,​O1,​I2,​O2,​M1,​M2>
      BidiFlow<I1,​O1,​I2,​O2,​NotUsed>
      fromFlows​(Graph<FlowShape<I1,​O1>,​M1> flow1, Graph<FlowShape<I2,​O2>,​M2> flow2)
      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, scala.Function2<M1,​M2,​M> combine)
      Wraps two Flows to create a ''BidiFlow''.
      static <I1,​O1,​I2,​O2>
      BidiFlow<I1,​O1,​I2,​O2,​NotUsed>
      fromFunctions​(scala.Function1<I1,​O1> outbound, scala.Function1<I2,​O2> inbound)
      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,​Mat>
      BidiFlow<I1,​O1,​I2,​O2,​Mat>
      fromGraph​(Graph<BidiShape<I1,​O1,​I2,​O2>,​Mat> graph)
      A graph with the shape of a flow logically is a flow, this method makes it so also in type.
      static <A,​B>
      BidiFlow<A,​A,​B,​B,​NotUsed>
      identity()  
      <Mat2> Flow<I1,​O2,​Mat> join​(Graph<FlowShape<O1,​I2>,​Mat2> flow)
      Add the given Flow as the final step in a bidirectional transformation pipeline.
      <Mat2,​M>
      Flow<I1,​O2,​M>
      joinMat​(Graph<FlowShape<O1,​I2>,​Mat2> flow, scala.Function2<Mat,​Mat2,​M> combine)
      Add the given Flow as the final step in a bidirectional transformation pipeline.
      <Mat2> BidiFlow<I1,​O1,​I2,​O2,​Mat2> mapMaterializedValue​(scala.Function1<Mat,​Mat2> f)
      Transform only the materialized value of this BidiFlow, leaving all other properties as they were.
      BidiFlow<I1,​O1,​I2,​O2,​Mat> named​(java.lang.String name)
      Add a name attribute to this Flow.
      BidiFlow<I2,​O2,​I1,​O1,​Mat> reversed()
      Turn this BidiFlow around by 180 degrees, logically flipping it upside down in a protocol stack.
      BidiShape<I1,​O1,​I2,​O2> shape()
      The shape of a graph is all that is externally visible: its inlets and outlets.
      TraversalBuilder traversalBuilder()
      INTERNAL API.
      BidiFlow<I1,​O1,​I2,​O2,​Mat> withAttributes​(Attributes attr)
      Change the attributes of this Source to the given ones and seal the list of attributes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • identity

        public static <A,​B> BidiFlow<A,​A,​B,​B,​NotUsed> identity()
      • fromGraph

        public static <I1,​O1,​I2,​O2,​Mat> BidiFlow<I1,​O1,​I2,​O2,​Mat> fromGraph​(Graph<BidiShape<I1,​O1,​I2,​O2>,​Mat> graph)
        A graph with the shape of a flow logically is a flow, this method makes it so also in type.
        Parameters:
        graph - (undocumented)
        Returns:
        (undocumented)
      • fromFlowsMat

        public 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,
                                                                                                                                             scala.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
             |  +----------------------+  |
             +----------------------------+
         

        Parameters:
        flow1 - (undocumented)
        flow2 - (undocumented)
        combine - (undocumented)
        Returns:
        (undocumented)
      • fromFlows

        public static <I1,​O1,​I2,​O2,​M1,​M2> BidiFlow<I1,​O1,​I2,​O2,​NotUsed> fromFlows​(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 Unit.

        
             +----------------------------+
             | Resulting BidiFlow         |
             |                            |
             |  +----------------------+  |
         I1 ~~> |        Flow1         | ~~> O1
             |  +----------------------+  |
             |                            |
             |  +----------------------+  |
         O2 <~~ |        Flow2         | <~~ I2
             |  +----------------------+  |
             +----------------------------+
         

        Parameters:
        flow1 - (undocumented)
        flow2 - (undocumented)
        Returns:
        (undocumented)
      • fromFunctions

        public static <I1,​O1,​I2,​O2> BidiFlow<I1,​O1,​I2,​O2,​NotUsed> fromFunctions​(scala.Function1<I1,​O1> outbound,
                                                                                                                          scala.Function1<I2,​O2> inbound)
        Create a BidiFlow where the top and bottom flows are just one simple mapping operator each, expressed by the two functions.
        Parameters:
        outbound - (undocumented)
        inbound - (undocumented)
        Returns:
        (undocumented)
      • bidirectionalIdleTimeout

        public static <I,​O> BidiFlow<I,​I,​O,​O,​NotUsed> bidirectionalIdleTimeout​(scala.concurrent.duration.FiniteDuration timeout)
        If the time between two processed elements *in any direction* exceed the provided timeout, the stream is failed with a scala.concurrent.TimeoutException.

        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.

        Parameters:
        timeout - (undocumented)
        Returns:
        (undocumented)
      • traversalBuilder

        public TraversalBuilder traversalBuilder()
        Description copied from interface: Graph
        INTERNAL API.

        Every materializable element must be backed by a stream layout module

        Specified by:
        traversalBuilder in interface Graph<I1,​O1>
        Returns:
        (undocumented)
      • shape

        public BidiShape<I1,​O1,​I2,​O2> shape()
        Description copied from interface: Graph
        The shape of a graph is all that is externally visible: its inlets and outlets.
        Specified by:
        shape in interface Graph<I1,​O1>
        Returns:
        (undocumented)
      • asJava

        public <JI1 extends I1,​JO1,​JI2 extends I2,​JO2,​JMat> BidiFlow<JI1,​JO1,​JI2,​JO2,​JMat> asJava()
      • atop

        public <OO1,​II2,​Mat2> BidiFlow<I1,​OO1,​II2,​O2,​Mat> atop​(Graph<BidiShape<O1,​OO1,​II2,​I2>,​Mat2> bidi)
        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.
        
             +----------------------------+
             | Resulting BidiFlow         |
             |                            |
             |  +------+        +------+  |
         I1 ~~> |      |  ~O1~> |      | ~~> OO1
             |  | this |        | bidi |  |
         O2 <~~ |      | <~I2~  |      | <~~ II2
             |  +------+        +------+  |
             +----------------------------+
         
        The materialized value of the combined BidiFlow will be the materialized value of the current flow (ignoring the other BidiFlow&rsquo;s value), use atopMat if a different strategy is needed.
        Parameters:
        bidi - (undocumented)
        Returns:
        (undocumented)
      • atopMat

        public <OO1,​II2,​Mat2,​M> BidiFlow<I1,​OO1,​II2,​O2,​M> atopMat​(Graph<BidiShape<O1,​OO1,​II2,​I2>,​Mat2> bidi,
                                                                                                            scala.Function2<Mat,​Mat2,​M> combine)
        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.
        
             +----------------------------+
             | Resulting BidiFlow         |
             |                            |
             |  +------+        +------+  |
         I1 ~~> |      |  ~O1~> |      | ~~> OO1
             |  | this |        | bidi |  |
         O2 <~~ |      | <~I2~  |      | <~~ II2
             |  +------+        +------+  |
             +----------------------------+
         
        The combine function is used to compose the materialized values of this flow and that flow into the materialized value of the resulting BidiFlow.
        Parameters:
        bidi - (undocumented)
        combine - (undocumented)
        Returns:
        (undocumented)
      • join

        public <Mat2> Flow<I1,​O2,​Mat> join​(Graph<FlowShape<O1,​I2>,​Mat2> flow)
        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.
        
             +---------------------------+
             | Resulting Flow            |
             |                           |
             |  +------+        +------+ |
         I1 ~~> |      |  ~O1~> |      | |
             |  | this |        | flow | |
         O2 <~~ |      | <~I2~  |      | |
             |  +------+        +------+ |
             +---------------------------+
         
        The materialized value of the combined Flow will be the materialized value of the current flow (ignoring the other Flow&rsquo;s value), use joinMat if a different strategy is needed.
        Parameters:
        flow - (undocumented)
        Returns:
        (undocumented)
      • joinMat

        public <Mat2,​M> Flow<I1,​O2,​M> joinMat​(Graph<FlowShape<O1,​I2>,​Mat2> flow,
                                                                scala.Function2<Mat,​Mat2,​M> combine)
        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.
        
             +---------------------------+
             | Resulting Flow            |
             |                           |
             |  +------+        +------+ |
         I1 ~~> |      |  ~O1~> |      | |
             |  | this |        | flow | |
         O2 <~~ |      | <~I2~  |      | |
             |  +------+        +------+ |
             +---------------------------+
         
        The combine function is used to compose the materialized values of this flow and that flow into the materialized value of the resulting Flow.
        Parameters:
        flow - (undocumented)
        combine - (undocumented)
        Returns:
        (undocumented)
      • reversed

        public BidiFlow<I2,​O2,​I1,​O1,​Mat> reversed()
        Turn this BidiFlow around by 180 degrees, logically flipping it upside down in a protocol stack.
        Returns:
        (undocumented)
      • mapMaterializedValue

        public <Mat2> BidiFlow<I1,​O1,​I2,​O2,​Mat2> mapMaterializedValue​(scala.Function1<Mat,​Mat2> f)
        Transform only the materialized value of this BidiFlow, leaving all other properties as they were.
        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
      • withAttributes

        public BidiFlow<I1,​O1,​I2,​O2,​Mat> withAttributes​(Attributes attr)
        Change the attributes of this Source 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 interface Graph<I1,​O1>
        Parameters:
        attr - (undocumented)
        Returns:
        (undocumented)
      • addAttributes

        public BidiFlow<I1,​O1,​I2,​O2,​Mat> addAttributes​(Attributes attr)
        Add the given attributes to this Source. Further calls to withAttributes 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 interface Graph<I1,​O1>
        Parameters:
        attr - (undocumented)
        Returns:
        (undocumented)
      • named

        public BidiFlow<I1,​O1,​I2,​O2,​Mat> named​(java.lang.String name)
        Add a name attribute to this Flow.
        Specified by:
        named in interface Graph<I1,​O1>
        Parameters:
        name - (undocumented)
        Returns:
        (undocumented)
      • async

        public BidiFlow<I1,​O1,​I2,​O2,​Mat> async()
        Put an asynchronous boundary around this BidiFlow
        Specified by:
        async in interface Graph<I1,​O1>
        Returns:
        (undocumented)
      • async

        public BidiFlow<I1,​O1,​I2,​O2,​Mat> async​(java.lang.String dispatcher)
        Put an asynchronous boundary around this BidiFlow

        Specified by:
        async in interface Graph<I1,​O1>
        Parameters:
        dispatcher - Run the graph on this dispatcher
        Returns:
        (undocumented)
      • async

        public BidiFlow<I1,​O1,​I2,​O2,​Mat> async​(java.lang.String dispatcher,
                                                                       int inputBufferSize)
        Put an asynchronous boundary around this BidiFlow

        Specified by:
        async in interface Graph<I1,​O1>
        Parameters:
        dispatcher - Run the graph on this dispatcher
        inputBufferSize - Set the input buffer to this size for the graph
        Returns:
        (undocumented)