FlowWithContextOps

org.apache.pekko.stream.scaladsl.FlowWithContextOps
trait FlowWithContextOps[+Out, +Ctx, +Mat]

Shared stream operations for FlowWithContext and SourceWithContext that automatically propagate a context element with each data element.

Attributes

Source
FlowWithContextOps.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class FlowWithContext[In, CtxIn, Out, CtxOut, Mat]
class SourceWithContext[Out, Ctx, Mat]

Members list

Type members

Types

type Repr[+O, +C] = ReprMat[O, C, Mat]

Attributes

Source
FlowWithContextOps.scala
type ReprMat[+O, +C, +M] <: FlowWithContextOps[O, C, M] { type ReprMat = ReprMat; }

Attributes

Source
FlowWithContextOps.scala

Value members

Abstract methods

def alsoTo(that: Graph[SinkShape[Out], _]): Repr[Out, Ctx]
def alsoToContext(that: Graph[SinkShape[Ctx], _]): Repr[Out, Ctx]
def unsafeDataVia[Out2, Mat2](viaFlow: Graph[FlowShape[Out, Out2], Mat2]): Repr[Out2, Ctx]

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
FlowWithContextOps.scala
def via[Out2, Ctx2, Mat2](flow: Graph[FlowShape[(Out, Ctx), (Out2, Ctx2)], Mat2]): Repr[Out2, Ctx2]

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
FlowWithContextOps.scala
def viaMat[Out2, Ctx2, Mat2, Mat3](flow: Graph[FlowShape[(Out, Ctx), (Out2, Ctx2)], Mat2])(combine: (Mat, Mat2) => Mat3): ReprMat[Out2, Ctx2, Mat3]

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.

The combine function is used to compose the materialized values of this flow and that flow into the materialized value of the resulting Flow.

Attributes

See also
Source
FlowWithContextOps.scala
def wireTap(that: Graph[SinkShape[Out], _]): Repr[Out, Ctx]
def wireTapContext(that: Graph[SinkShape[Ctx], _]): Repr[Out, Ctx]

Concrete methods

def collect[Out2](f: PartialFunction[Out, Out2]): Repr[Out2, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.collect.

Context-preserving variant of pekko.stream.scaladsl.FlowOps.collect.

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

Attributes

See also
Source
FlowWithContextOps.scala
def filter(pred: Out => Boolean): Repr[Out, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.filter.

Context-preserving variant of pekko.stream.scaladsl.FlowOps.filter.

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

Attributes

See also
Source
FlowWithContextOps.scala
def filterNot(pred: Out => Boolean): Repr[Out, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.filterNot.

Context-preserving variant of pekko.stream.scaladsl.FlowOps.filterNot.

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

Attributes

See also
Source
FlowWithContextOps.scala
def grouped(n: Int): Repr[Seq[Out], Seq[Ctx]]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.grouped.

Context-preserving variant of pekko.stream.scaladsl.FlowOps.grouped.

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

Attributes

See also
Source
FlowWithContextOps.scala
def log(name: String, extract: Out => Any)(implicit log: LoggingAdapter): Repr[Out, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.log.

Context-preserving variant of pekko.stream.scaladsl.FlowOps.log.

Attributes

See also
Source
FlowWithContextOps.scala
def logWithMarker(name: String, marker: (Out, Ctx) => LogMarker, extract: Out => Any)(implicit log: MarkerLoggingAdapter): Repr[Out, Ctx]
def map[Out2](f: Out => Out2): Repr[Out2, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.map.

Context-preserving variant of pekko.stream.scaladsl.FlowOps.map.

Attributes

See also
Source
FlowWithContextOps.scala
def mapAsync[Out2](parallelism: Int)(f: Out => Future[Out2]): Repr[Out2, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.mapAsync.

def mapAsyncPartitioned[Out2, P](parallelism: Int)(partitioner: Out => P)(f: (Out, P) => Future[Out2]): Repr[Out2, Ctx]
def mapAsyncPartitionedUnordered[Out2, P](parallelism: Int)(partitioner: Out => P)(f: (Out, P) => Future[Out2]): Repr[Out2, Ctx]
def mapConcat[Out2](f: Out => IterableOnce[Out2]): Repr[Out2, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.mapConcat.

Context-preserving variant of pekko.stream.scaladsl.FlowOps.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
FlowWithContextOps.scala
def mapContext[Ctx2](f: Ctx => Ctx2): Repr[Out, Ctx2]

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
FlowWithContextOps.scala
def sliding(n: Int, step: Int): Repr[Seq[Out], Seq[Ctx]]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.sliding.

Context-preserving variant of pekko.stream.scaladsl.FlowOps.sliding.

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

Attributes

See also
Source
FlowWithContextOps.scala
def throttle(elements: Int, per: FiniteDuration): Repr[Out, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.throttle.

def throttle(elements: Int, per: FiniteDuration, maximumBurst: Int, mode: ThrottleMode): Repr[Out, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.throttle.

def throttle(cost: Int, per: FiniteDuration, costCalculation: Out => Int): Repr[Out, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.throttle.

def throttle(cost: Int, per: FiniteDuration, maximumBurst: Int, costCalculation: Out => Int, mode: ThrottleMode): Repr[Out, Ctx]

Context-preserving variant of pekko.stream.scaladsl.FlowOps.throttle.