Class SourceWithContext<Out,​Ctx,​Mat>

  • All Implemented Interfaces:
    Graph<SourceShape<scala.Tuple2<Out,​Ctx>>,​Mat>

    public final class SourceWithContext<Out,​Ctx,​Mat>
    extends GraphDelegate<SourceShape<scala.Tuple2<Out,​Ctx>>,​Mat>
    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.

    See Also:
    akka.stream.javadsl.Flow.via
    • Method Detail

      • fromPairs

        public static <Out,​CtxOut,​Mat> SourceWithContext<Out,​CtxOut,​Mat> fromPairs​(Source<Pair<Out,​CtxOut>,​Mat> under)
      • withAttributes

        public SourceWithContext<Out,​Ctx,​Mat> withAttributes​(Attributes attr)
        Context-preserving variant of akka.stream.javadsl.Source.withAttributes.

        Parameters:
        attr - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Source.withAttributes
      • mapMaterializedValue

        public <Mat2> SourceWithContext<Out,​Ctx,​Mat2> mapMaterializedValue​(Function<Mat,​Mat2> f)
        Context-preserving variant of akka.stream.javadsl.Source.mapMaterializedValue.

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

        public Source<Pair<Out,​Ctx>,​Mat> asSource()
        Stops automatic context propagation from here and converts this to a regular stream of a pair of (data, context).
        Returns:
        (undocumented)
      • collect

        public <Out2> SourceWithContext<Out2,​Ctx,​Mat> collect​(scala.PartialFunction<Out,​Out2> pf)
        Context-preserving variant of akka.stream.javadsl.Source.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.Source.collect
      • filter

        public SourceWithContext<Out,​Ctx,​Mat> filter​(Predicate<Out> p)
        Context-preserving variant of akka.stream.javadsl.Source.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.Source.filter
      • filterNot

        public SourceWithContext<Out,​Ctx,​Mat> filterNot​(Predicate<Out> p)
        Context-preserving variant of akka.stream.javadsl.Source.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.Source.filterNot
      • grouped

        public SourceWithContext<java.util.List<Out>,​java.util.List<Ctx>,​Mat> grouped​(int n)
        Context-preserving variant of akka.stream.javadsl.Source.grouped.

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

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

        public <Out2> SourceWithContext<Out2,​Ctx,​Mat> map​(Function<Out,​Out2> f)
        Context-preserving variant of akka.stream.javadsl.Source.map.

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

        public <Out2> SourceWithContext<Out2,​Ctx,​Mat> mapConcat​(Function<Out,​? extends java.lang.Iterable<Out2>> f)
        Context-preserving variant of akka.stream.javadsl.Source.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.Source.mapConcat
      • mapContext

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

        public SourceWithContext<java.util.List<Out>,​java.util.List<Ctx>,​Mat> sliding​(int n,
                                                                                                  int step)
        Context-preserving variant of akka.stream.javadsl.Source.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.Source.sliding
      • sliding$default$2

        public int sliding$default$2()
      • log

        public SourceWithContext<Out,​Ctx,​Mat> log​(java.lang.String name,
                                                              Function<Out,​java.lang.Object> extract,
                                                              LoggingAdapter log)
        Context-preserving variant of akka.stream.javadsl.Source.log.

        Parameters:
        name - (undocumented)
        extract - (undocumented)
        log - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Source.log
      • log

        public SourceWithContext<Out,​Ctx,​Mat> log​(java.lang.String name,
                                                              Function<Out,​java.lang.Object> extract)
        Context-preserving variant of akka.stream.javadsl.Flow.log.

        Parameters:
        name - (undocumented)
        extract - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.log
      • log

        public SourceWithContext<Out,​Ctx,​Mat> log​(java.lang.String name,
                                                              LoggingAdapter log)
        Context-preserving variant of akka.stream.javadsl.Flow.log.

        Parameters:
        name - (undocumented)
        log - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.log
      • log

        public SourceWithContext<Out,​Ctx,​Mat> log​(java.lang.String name)
        Context-preserving variant of akka.stream.javadsl.Flow.log.

        Parameters:
        name - (undocumented)
        Returns:
        (undocumented)
        See Also:
        akka.stream.javadsl.Flow.log
      • runWith

        public <M> M runWith​(Graph<SinkShape<Pair<Out,​Ctx>>,​M> sink,
                             Materializer materializer)
        Connect this SourceWithContext to a Sink and run it. The returned value is the materialized value of the Sink.
        Parameters:
        sink - (undocumented)
        materializer - (undocumented)
        Returns:
        (undocumented)