Class SourceWithContext<Out,Ctx,Mat>
- java.lang.Object
-
- akka.stream.GraphDelegate<SourceShape<scala.Tuple2<Out,Ctx>>,Mat>
-
- akka.stream.javadsl.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
-
-
Constructor Summary
Constructors Constructor Description SourceWithContext(SourceWithContext<Out,Ctx,Mat> delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SourceWithContext<Out,Ctx,Mat>
asScala()
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).<Out2> SourceWithContext<Out2,Ctx,Mat>
collect(scala.PartialFunction<Out,Out2> pf)
Context-preserving variant ofakka.stream.javadsl.Source.collect
.SourceWithContext<Out,Ctx,Mat>
filter(Predicate<Out> p)
Context-preserving variant ofakka.stream.javadsl.Source.filter
.SourceWithContext<Out,Ctx,Mat>
filterNot(Predicate<Out> p)
Context-preserving variant ofakka.stream.javadsl.Source.filterNot
.static <Out,CtxOut,Mat>
SourceWithContext<Out,CtxOut,Mat>fromPairs(Source<Pair<Out,CtxOut>,Mat> under)
SourceWithContext<java.util.List<Out>,java.util.List<Ctx>,Mat>
grouped(int n)
Context-preserving variant ofakka.stream.javadsl.Source.grouped
.SourceWithContext<Out,Ctx,Mat>
log(java.lang.String name)
Context-preserving variant ofakka.stream.javadsl.Flow.log
.SourceWithContext<Out,Ctx,Mat>
log(java.lang.String name, LoggingAdapter log)
Context-preserving variant ofakka.stream.javadsl.Flow.log
.SourceWithContext<Out,Ctx,Mat>
log(java.lang.String name, Function<Out,java.lang.Object> extract)
Context-preserving variant ofakka.stream.javadsl.Flow.log
.SourceWithContext<Out,Ctx,Mat>
log(java.lang.String name, Function<Out,java.lang.Object> extract, LoggingAdapter log)
Context-preserving variant ofakka.stream.javadsl.Source.log
.<Out2> SourceWithContext<Out2,Ctx,Mat>
map(Function<Out,Out2> f)
Context-preserving variant ofakka.stream.javadsl.Source.map
.<Out2> SourceWithContext<Out2,Ctx,Mat>
mapAsync(int parallelism, Function<Out,java.util.concurrent.CompletionStage<Out2>> f)
<Out2> SourceWithContext<Out2,Ctx,Mat>
mapConcat(Function<Out,? extends java.lang.Iterable<Out2>> f)
Context-preserving variant ofakka.stream.javadsl.Source.mapConcat
.<Ctx2> SourceWithContext<Out,Ctx2,Mat>
mapContext(Function<Ctx,Ctx2> extractContext)
Apply the given function to each context element (leaving the data elements unchanged).<Mat2> SourceWithContext<Out,Ctx,Mat2>
mapMaterializedValue(Function<Mat,Mat2> f)
Context-preserving variant ofakka.stream.javadsl.Source.mapMaterializedValue
.<M> M
runWith(Graph<SinkShape<Pair<Out,Ctx>>,M> sink, Materializer materializer)
Connect thisSourceWithContext
to aSink
and run it.SourceWithContext<java.util.List<Out>,java.util.List<Ctx>,Mat>
sliding(int n, int step)
Context-preserving variant ofakka.stream.javadsl.Source.sliding
.int
sliding$default$2()
<Mat2> RunnableGraph<Mat>
to(Graph<SinkShape<Pair<Out,Ctx>>,Mat2> sink)
Connect thisSourceWithContext
to aSink
, concatenating the processing steps of both.<Mat2,Mat3>
RunnableGraph<Mat3>toMat(Graph<SinkShape<Pair<Out,Ctx>>,Mat2> sink, Function2<Mat,Mat2,Mat3> combine)
Connect thisSourceWithContext
to aSink
, concatenating the processing steps of both.<Out2,Ctx2,Mat2>
SourceWithContext<Out2,Ctx2,Mat>via(Graph<FlowShape<Pair<Out,Ctx>,Pair<Out2,Ctx2>>,Mat2> viaFlow)
SourceWithContext<Out,Ctx,Mat>
withAttributes(Attributes attr)
Context-preserving variant ofakka.stream.javadsl.Source.withAttributes
.-
Methods inherited from class akka.stream.GraphDelegate
shape, traversalBuilder
-
-
-
-
Constructor Detail
-
SourceWithContext
public SourceWithContext(SourceWithContext<Out,Ctx,Mat> delegate)
-
-
Method Detail
-
fromPairs
public static <Out,CtxOut,Mat> SourceWithContext<Out,CtxOut,Mat> fromPairs(Source<Pair<Out,CtxOut>,Mat> under)
-
via
public <Out2,Ctx2,Mat2> SourceWithContext<Out2,Ctx2,Mat> via(Graph<FlowShape<Pair<Out,Ctx>,Pair<Out2,Ctx2>>,Mat2> viaFlow)
-
withAttributes
public SourceWithContext<Out,Ctx,Mat> withAttributes(Attributes attr)
Context-preserving variant ofakka.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 ofakka.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 ofakka.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 ofakka.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 ofakka.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 ofakka.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 ofakka.stream.javadsl.Source.map
.- Parameters:
f
- (undocumented)- Returns:
- (undocumented)
- See Also:
akka.stream.javadsl.Source.map
-
mapAsync
public <Out2> SourceWithContext<Out2,Ctx,Mat> mapAsync(int parallelism, Function<Out,java.util.concurrent.CompletionStage<Out2>> f)
-
mapConcat
public <Out2> SourceWithContext<Out2,Ctx,Mat> mapConcat(Function<Out,? extends java.lang.Iterable<Out2>> f)
Context-preserving variant ofakka.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 ofakka.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 ofakka.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 ofakka.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 ofakka.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 ofakka.stream.javadsl.Flow.log
.- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
- See Also:
akka.stream.javadsl.Flow.log
-
to
public <Mat2> RunnableGraph<Mat> to(Graph<SinkShape<Pair<Out,Ctx>>,Mat2> sink)
Connect thisSourceWithContext
to aSink
, concatenating the processing steps of both.- Parameters:
sink
- (undocumented)- Returns:
- (undocumented)
-
toMat
public <Mat2,Mat3> RunnableGraph<Mat3> toMat(Graph<SinkShape<Pair<Out,Ctx>>,Mat2> sink, Function2<Mat,Mat2,Mat3> combine)
Connect thisSourceWithContext
to aSink
, concatenating the processing steps of both.- Parameters:
sink
- (undocumented)combine
- (undocumented)- Returns:
- (undocumented)
-
runWith
public <M> M runWith(Graph<SinkShape<Pair<Out,Ctx>>,M> sink, Materializer materializer)
Connect thisSourceWithContext
to aSink
and run it. The returned value is the materialized value of theSink
.- Parameters:
sink
- (undocumented)materializer
- (undocumented)- Returns:
- (undocumented)
-
asScala
public SourceWithContext<Out,Ctx,Mat> asScala()
-
-