FlowWithContext

org.apache.pekko.stream.javadsl.FlowWithContext
See theFlowWithContext companion object
final class FlowWithContext[In, CtxIn, Out, CtxOut, +Mat](delegate: Flow[Pair[In, CtxIn], Pair[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].

Attributes

Companion
object
Source
FlowWithContext.scala
Graph
Supertypes
trait Graph[FlowShape[Pair[In, CtxIn], Pair[Out, CtxOut]], Mat]
class Object
trait Matchable
class Any

Members list

Type members

Inherited types

type Shape = FlowShape[Pair[In, CtxIn], Pair[Out, CtxOut]]

Type-level accessor for the shape parameter of this graph.

Type-level accessor for the shape parameter of this graph.

Attributes

Inherited from:
Graph
Source
Graph.scala

Value members

Concrete methods

def asFlow(): Flow[Pair[In, CtxIn], Pair[Out, CtxOut], Mat]

Creates a regular flow of pairs (data, context).

Creates a regular flow of pairs (data, context).

Attributes

Source
FlowWithContext.scala
def asScala: FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Attributes

Source
FlowWithContext.scala
def collect[Out2](pf: PartialFunction[Out, Out2]): FlowWithContext[In, CtxIn, Out2, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.collect.

Context-preserving variant of pekko.stream.javadsl.Flow.collect.

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

Attributes

See also
Source
FlowWithContext.scala
def filter(p: Predicate[Out]): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.filter.

Context-preserving variant of pekko.stream.javadsl.Flow.filter.

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

Attributes

See also
Source
FlowWithContext.scala
def filterNot(p: Predicate[Out]): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.filterNot.

Context-preserving variant of pekko.stream.javadsl.Flow.filterNot.

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

Attributes

See also
Source
FlowWithContext.scala
def grouped(n: Int): FlowWithContext[In, CtxIn, List[Out], List[CtxOut], Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.grouped.

Context-preserving variant of pekko.stream.javadsl.Flow.grouped.

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

Attributes

See also
Source
FlowWithContext.scala
def log(name: String, extract: Function[Out, Any], log: LoggingAdapter): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.log.

Context-preserving variant of pekko.stream.javadsl.Flow.log.

Attributes

See also
Source
FlowWithContext.scala
def log(name: String, extract: Function[Out, Any]): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.log.

Context-preserving variant of pekko.stream.javadsl.Flow.log.

Attributes

See also
Source
FlowWithContext.scala
def log(name: String, log: LoggingAdapter): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.log.

Context-preserving variant of pekko.stream.javadsl.Flow.log.

Attributes

See also
Source
FlowWithContext.scala
def log(name: String): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.log.

Context-preserving variant of pekko.stream.javadsl.Flow.log.

Attributes

See also
Source
FlowWithContext.scala
def logWithMarker(name: String, marker: Function2[Out, CtxOut, LogMarker], extract: Function[Out, Any], log: MarkerLoggingAdapter): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.logWithMarker.

def logWithMarker(name: String, marker: Function2[Out, CtxOut, LogMarker], extract: Function[Out, Any]): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.logWithMarker.

def logWithMarker(name: String, marker: Function2[Out, CtxOut, LogMarker], log: MarkerLoggingAdapter): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.logWithMarker.

def logWithMarker(name: String, marker: Function2[Out, CtxOut, LogMarker]): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.logWithMarker.

def map[Out2](f: Function[Out, Out2]): FlowWithContext[In, CtxIn, Out2, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.map.

Context-preserving variant of pekko.stream.javadsl.Flow.map.

Attributes

See also
Source
FlowWithContext.scala
def mapAsync[Out2](parallelism: Int, f: Function[Out, CompletionStage[Out2]]): FlowWithContext[In, CtxIn, Out2, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.mapAsync.

Context-preserving variant of pekko.stream.javadsl.Flow.mapAsync.

Attributes

See also
Source
FlowWithContext.scala
def mapAsyncPartitioned[Out2, P](parallelism: Int, partitioner: Function[Out, P], f: Function2[Out, P, CompletionStage[Out2]]): FlowWithContext[In, CtxIn, Out2, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.mapAsyncPartitioned.

Context-preserving variant of pekko.stream.javadsl.Flow.mapAsyncPartitioned.

Attributes

See also
Since

1.1.0

Source
FlowWithContext.scala
def mapAsyncPartitionedUnordered[Out2, P](parallelism: Int, partitioner: Function[Out, P], f: Function2[Out, P, CompletionStage[Out2]]): FlowWithContext[In, CtxIn, Out2, CtxOut, Mat]
def mapConcat[Out2](f: Function[Out, _ <: Iterable[Out2]]): FlowWithContext[In, CtxIn, Out2, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.mapConcat.

Context-preserving variant of pekko.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)

Attributes

See also
Source
FlowWithContext.scala
def mapContext[CtxOut2](extractContext: Function[CtxOut, CtxOut2]): FlowWithContext[In, CtxIn, Out, CtxOut2, Mat]

Apply the given function to each context element (leaving the data elements unchanged).

Apply the given function to each context element (leaving the data elements unchanged).

Attributes

Source
FlowWithContext.scala
def mapError(pf: PartialFunction[Throwable, Throwable]): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.mapError.

Context-preserving variant of pekko.stream.javadsl.Flow.mapError.

Attributes

See also
Source
FlowWithContext.scala
def mapMaterializedValue[Mat2](f: Function[Mat, Mat2]): FlowWithContext[In, CtxIn, Out, CtxOut, Mat2]
def sliding(n: Int, step: Int): FlowWithContext[In, CtxIn, List[Out], List[CtxOut], Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.sliding.

Context-preserving variant of pekko.stream.javadsl.Flow.sliding.

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

Attributes

See also
Source
FlowWithContext.scala
def throttle(elements: Int, per: Duration): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.throttle.

Context-preserving variant of pekko.stream.javadsl.Flow.throttle.

Attributes

See also
Source
FlowWithContext.scala
def throttle(elements: Int, per: Duration, maximumBurst: Int, mode: ThrottleMode): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.throttle.

Context-preserving variant of pekko.stream.javadsl.Flow.throttle.

Attributes

See also
Source
FlowWithContext.scala
def throttle(cost: Int, per: Duration, costCalculation: Function[Out, Integer]): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.throttle.

Context-preserving variant of pekko.stream.javadsl.Flow.throttle.

Attributes

See also
Source
FlowWithContext.scala
def throttle(cost: Int, per: Duration, maximumBurst: Int, costCalculation: Function[Out, Integer], mode: ThrottleMode): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.throttle.

Context-preserving variant of pekko.stream.javadsl.Flow.throttle.

Attributes

See also
Source
FlowWithContext.scala
def unsafeDataVia[Out2, Mat2](viaFlow: Graph[FlowShape[Out, Out2], Mat2]): FlowWithContext[In, CtxIn, Out2, CtxOut, Mat]

Transform this flow by the regular flow. The given flow works on the data portion of the stream and ignores the context.

Transform this flow by the regular flow. The given flow works on the data portion of the stream and ignores the context.

The given flow must not re-order, drop or emit multiple elements for one incoming element, the sequence of incoming contexts is re-combined with the outgoing elements of the stream. If a flow not fulfilling this requirement is used the stream will not fail but continue running in a corrupt state and re-combine incorrect pairs of elements and contexts or deadlock.

For more background on these requirements see https://pekko.apache.org/docs/pekko/current/stream/stream-context.html.

Attributes

Source
FlowWithContext.scala
def via[Out2, CtxOut2, Mat2](viaFlow: Graph[FlowShape[Pair[Out, CtxOut], Pair[Out2, CtxOut2]], Mat2]): FlowWithContext[In, CtxIn, Out2, CtxOut2, Mat]

Transform this flow by the regular flow. The given flow must support manual context propagation by taking and producing tuples of (data, context).

Transform this flow by the regular flow. The given flow must support manual context propagation by taking and producing tuples of (data, context).

It is up to the implementer to ensure the inner flow does not exhibit any behavior that is not expected by the downstream elements, such as reordering. For more background on these requirements see https://pekko.apache.org/docs/pekko/current/stream/stream-context.html.

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

Attributes

See also
Source
FlowWithContext.scala
override def withAttributes(attr: Attributes): FlowWithContext[In, CtxIn, Out, CtxOut, Mat]

Context-preserving variant of pekko.stream.javadsl.Flow.withAttributes.

Context-preserving variant of pekko.stream.javadsl.Flow.withAttributes.

Attributes

See also
Definition Classes
Source
FlowWithContext.scala

Inherited methods

def addAttributes(attr: Attributes): Graph[FlowShape[Pair[In, CtxIn], Pair[Out, CtxOut]], Mat]

Add the given attributes to this Graph. If the specific attribute was already present on this graph this means the added attribute will be more specific than the existing one. If this Source is a composite of multiple graphs, new attributes on the composite will be less specific than attributes set directly on the individual graphs of the composite.

Add the given attributes to this Graph. If the specific attribute was already present on this graph this means the added attribute will be more specific than the existing one. If this Source is a composite of multiple graphs, new attributes on the composite will be less specific than attributes set directly on the individual graphs of the composite.

Attributes

Inherited from:
Graph
Source
Graph.scala
def async(dispatcher: String, inputBufferSize: Int): Graph[FlowShape[Pair[In, CtxIn], Pair[Out, CtxOut]], Mat]

Put an asynchronous boundary around this Graph

Put an asynchronous boundary around this Graph

Value parameters

dispatcher

Run the graph on this dispatcher

inputBufferSize

Set the input buffer to this size for the graph

Attributes

Inherited from:
Graph
Source
Graph.scala
def async(dispatcher: String): Graph[FlowShape[Pair[In, CtxIn], Pair[Out, CtxOut]], Mat]

Put an asynchronous boundary around this Graph

Put an asynchronous boundary around this Graph

Value parameters

dispatcher

Run the graph on this dispatcher

Attributes

Inherited from:
Graph
Source
Graph.scala
def async: Graph[FlowShape[Pair[In, CtxIn], Pair[Out, CtxOut]], Mat]

Put an asynchronous boundary around this Graph

Put an asynchronous boundary around this Graph

Attributes

Inherited from:
Graph
Source
Graph.scala

Attributes

Inherited from:
Graph
Source
Graph.scala
def named(name: String): Graph[FlowShape[Pair[In, CtxIn], Pair[Out, CtxOut]], Mat]

Specifies the name of the Graph. If the name is null or empty the name is ignored, i.e. Attributes.none is returned.

Specifies the name of the Graph. If the name is null or empty the name is ignored, i.e. Attributes.none is returned.

Attributes

Inherited from:
Graph
Source
Graph.scala
final override def shape: FlowShape[Pair[In, CtxIn], Pair[Out, CtxOut]]

The shape of a graph is all that is externally visible: its inlets and outlets.

The shape of a graph is all that is externally visible: its inlets and outlets.

Attributes

Definition Classes
GraphDelegate -> Graph
Inherited from:
GraphDelegate (hidden)
Source
Graph.scala