Class FlowWithContext<CtxIn,​In,​CtxOut,​Out,​Mat>

  • All Implemented Interfaces:
    Graph<FlowShape<scala.Tuple2<In,​CtxIn>,​scala.Tuple2<Out,​CtxOut>>,​Mat>

    public final class FlowWithContext<CtxIn,​In,​CtxOut,​Out,​Mat>
    extends GraphDelegate<FlowShape<scala.Tuple2<In,​CtxIn>,​scala.Tuple2<Out,​CtxOut>>,​Mat>
    A flow that provides operations which automatically propagate the context of an element. Only a subset of common operations from Flow is supported. As an escape hatch you can use FlowWithContext.via to manually provide the context propagation for otherwise unsupported operations.

    An "empty" flow can be created by calling FlowWithContext[Ctx, T].

    API MAY CHANGE

    • Method Detail

      • fromPairs

        public static <CtxIn,​In,​CtxOut,​Out,​Mat> FlowWithContext<CtxIn,​In,​CtxOut,​Out,​Mat> fromPairs​(Flow<Pair<In,​CtxIn>,​Pair<Out,​CtxOut>,​Mat> under)
      • named

        public static Graph<S,​M> named​(java.lang.String name)
      • async

        public static Graph<S,​M> async()
      • async

        public static Graph<S,​M> async​(java.lang.String dispatcher)
      • async

        public static Graph<S,​M> async​(java.lang.String dispatcher,
                                             int inputBufferSize)
      • addAttributes

        public static Graph<S,​M> addAttributes​(Attributes attr)
      • shape

        public static final S shape()
      • withAttributes

        public static final Graph<S,​Mat> withAttributes​(Attributes attr)
      • via

        public <CtxOut2,​Out2,​Mat2> FlowWithContext<CtxIn,​In,​CtxOut2,​Out2,​Mat> via​(Graph<FlowShape<Pair<Out,​CtxOut>,​Pair<Out2,​CtxOut2>>,​Mat2> viaFlow)
        Transform this flow by the regular flow. The given flow must support manual context propagation by taking and producing tuples of (data, context).

        This can be used as an escape hatch for operations that are not (yet) provided with automatic context propagation here.

        Parameters:
        viaFlow - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.via
      • collect

        public <Out2> FlowWithContext<CtxIn,​In,​CtxOut,​Out2,​Mat> collect​(scala.PartialFunction<Out,​Out2> pf)
        Context-preserving variant of akka.stream.javadsl.Flow.collect.

        Note, that the context of elements that are filtered out is skipped as well.

        Parameters:
        pf - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.collect
      • filter

        public FlowWithContext<CtxIn,​In,​CtxOut,​Out,​Mat> filter​(Predicate<Out> p)
        Context-preserving variant of akka.stream.javadsl.Flow.filter.

        Note, that the context of elements that are filtered out is skipped as well.

        Parameters:
        p - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.filter
      • filterNot

        public FlowWithContext<CtxIn,​In,​CtxOut,​Out,​Mat> filterNot​(Predicate<Out> p)
        Context-preserving variant of akka.stream.javadsl.Flow.filterNot.

        Note, that the context of elements that are filtered out is skipped as well.

        Parameters:
        p - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.filterNot
      • grouped

        public FlowWithContext<CtxIn,​In,​java.util.List<CtxOut>,​java.util.List<Out>,​Mat> grouped​(int n)
        Context-preserving variant of akka.stream.javadsl.Flow.grouped.

        Each output group will be associated with a Seq of corresponding context elements.

        Parameters:
        n - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.grouped
      • map

        public <Out2> FlowWithContext<CtxIn,​In,​CtxOut,​Out2,​Mat> map​(Function<Out,​Out2> f)
        Context-preserving variant of akka.stream.javadsl.Flow.map.

        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.map
      • mapConcat

        public <Out2> FlowWithContext<CtxIn,​In,​CtxOut,​Out2,​Mat> mapConcat​(Function<Out,​? extends java.lang.Iterable<Out2>> f)
        Context-preserving variant of akka.stream.javadsl.Flow.mapConcat.

        The context of the input element will be associated with each of the output elements calculated from this input element.

        Example:

        def dup(element: String) = Seq(element, element)

        Input:

        ("a", 1) ("b", 2)

        inputElements.mapConcat(dup)

        Output:

        ("a", 1) ("a", 1) ("b", 2) ("b", 2)

        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.mapConcat
      • mapContext

        public <CtxOut2> FlowWithContext<CtxIn,​In,​CtxOut2,​Out,​Mat> mapContext​(Function<CtxOut,​CtxOut2> extractContext)
        Apply the given function to each context element (leaving the data elements unchanged).
        Parameters:
        extractContext - (undocumented)
        Returns:
        (undocumented)
      • sliding

        public FlowWithContext<CtxIn,​In,​java.util.List<CtxOut>,​java.util.List<Out>,​Mat> sliding​(int n,
                                                                                                                        int step)
        Context-preserving variant of akka.stream.javadsl.Flow.sliding.

        Each output group will be associated with a Seq of corresponding context elements.

        Parameters:
        n - (undocumented)
        step - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.sliding
      • sliding$default$2

        public int sliding$default$2()
      • statefulMapConcat

        public <Out2> FlowWithContext<CtxIn,​In,​CtxOut,​Out2,​Mat> statefulMapConcat​(Creator<Function<Out,​java.lang.Iterable<Out2>>> f)
        Context-preserving variant of akka.stream.javadsl.Flow.statefulMapConcat.

        The context of the input element will be associated with each of the output elements calculated from this input element.

        Example:

        def dup(element: String) = Seq(element, element)

        Input:

        ("a", 1) ("b", 2)

        inputElements.statefulMapConcat(() => dup)

        Output:

        ("a", 1) ("a", 1) ("b", 2) ("b", 2)

        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.statefulMapConcat