SourceWithContext

org.apache.pekko.stream.scaladsl.SourceWithContext
See theSourceWithContext companion object
final class SourceWithContext[+Out, +Ctx, +Mat] extends FlowWithContextOps[Out, Ctx, Mat]

A source that provides operations which automatically propagate the context of an element. Only a subset of common operations from FlowOps is supported. As an escape hatch you can use FlowWithContextOps.via to manually provide the context propagation for otherwise unsupported operations.

Can be created by calling Source.asSourceWithContext

Attributes

Companion
object
Source
SourceWithContext.scala
Graph
Supertypes
trait FlowWithContextOps[Out, Ctx, Mat]
trait Graph[SourceShape[(Out, Ctx)], Mat]
class Object
trait Matchable
class Any

Members list

Type members

Types

override type ReprMat[+O, +C, +M] = SourceWithContext[O, C, M]

Attributes

Source
SourceWithContext.scala

Inherited types

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

Attributes

Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala
type Shape = SourceShape[(Out, Ctx)]

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 asJava[JOut >: Out, JCtx >: Ctx, JMat >: Mat]: SourceWithContext[JOut, JCtx, JMat]

Attributes

Source
SourceWithContext.scala
def asSource: Source[(Out, Ctx), Mat]

Stops automatic context propagation from here and converts this to a regular stream of a pair of (data, context).

Stops automatic context propagation from here and converts this to a regular stream of a pair of (data, context).

Attributes

Source
SourceWithContext.scala
def mapMaterializedValue[Mat2](f: Mat => Mat2): SourceWithContext[Out, Ctx, Mat2]
def runWith[Mat2](sink: Graph[SinkShape[(Out, Ctx)], Mat2])(implicit materializer: Materializer): Mat2

Connect this pekko.stream.scaladsl.SourceWithContext to a pekko.stream.scaladsl.Sink and run it. The returned value is the materialized value of the Sink.

Connect this pekko.stream.scaladsl.SourceWithContext to a pekko.stream.scaladsl.Sink and run it. The returned value is the materialized value of the Sink.

Note that the ActorSystem can be used as the implicit materializer parameter to use the pekko.stream.SystemMaterializer for running the stream.

Attributes

Source
SourceWithContext.scala
def to[Mat2](sink: Graph[SinkShape[(Out, Ctx)], Mat2]): RunnableGraph[Mat]

Connect this pekko.stream.scaladsl.SourceWithContext to a pekko.stream.scaladsl.Sink, concatenating the processing steps of both.

Connect this pekko.stream.scaladsl.SourceWithContext to a pekko.stream.scaladsl.Sink, concatenating the processing steps of both.

Attributes

Source
SourceWithContext.scala
def toMat[Mat2, Mat3](sink: Graph[SinkShape[(Out, Ctx)], Mat2])(combine: (Mat, Mat2) => Mat3): RunnableGraph[Mat3]

Connect this pekko.stream.scaladsl.SourceWithContext to a pekko.stream.scaladsl.Sink, concatenating the processing steps of both.

Connect this pekko.stream.scaladsl.SourceWithContext to a pekko.stream.scaladsl.Sink, concatenating the processing steps of both.

Attributes

Source
SourceWithContext.scala
override 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

Definition Classes
Source
SourceWithContext.scala
override def via[Out2, Ctx2, Mat2](viaFlow: 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
Definition Classes
Source
SourceWithContext.scala
override def viaMat[Out2, Ctx2, Mat2, Mat3](flow: Graph[FlowShape[(Out, Ctx), (Out2, Ctx2)], Mat2])(combine: (Mat, Mat2) => Mat3): SourceWithContext[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
Definition Classes
Source
SourceWithContext.scala
override def withAttributes(attr: Attributes): SourceWithContext[Out, Ctx, Mat]

Context-preserving variant of pekko.stream.scaladsl.Source.withAttributes.

Context-preserving variant of pekko.stream.scaladsl.Source.withAttributes.

Attributes

See also
Definition Classes
Source
SourceWithContext.scala

Inherited methods

def addAttributes(attr: Attributes): Graph[SourceShape[(Out, Ctx)], 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[SourceShape[(Out, Ctx)], 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[SourceShape[(Out, Ctx)], 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[SourceShape[(Out, Ctx)], Mat]

Put an asynchronous boundary around this Graph

Put an asynchronous boundary around this Graph

Attributes

Inherited from:
Graph
Source
Graph.scala
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
Inherited from:
FlowWithContextOps
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
Inherited from:
FlowWithContextOps
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
Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala

Attributes

Inherited from:
Graph
Source
Graph.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
Inherited from:
FlowWithContextOps
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
Inherited from:
FlowWithContextOps
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
Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala
def mapAsync[Out2](parallelism: Int)(f: Out => Future[Out2]): Repr[Out2, Ctx]

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

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

Attributes

See also
Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala
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
Inherited from:
FlowWithContextOps
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

Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala

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

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

Attributes

See also
Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala
def named(name: String): Graph[SourceShape[(Out, Ctx)], Mat]

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

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

Attributes

Inherited from:
Graph
Source
Graph.scala
final override def shape: SourceShape[(Out, Ctx)]

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
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
Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala
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.

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

Attributes

See also
Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala
def throttle(cost: Int, per: FiniteDuration, costCalculation: Out => Int): Repr[Out, Ctx]

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

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

Attributes

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

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

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

Attributes

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

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

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

Attributes

See also
Inherited from:
FlowWithContextOps
Source
FlowWithContextOps.scala