Search Results for

    Show / Hide Table of Contents

    Class SourceOperations

    TBD

    Inheritance
    object
    SourceOperations
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Streams.Dsl
    Assembly: Akka.Streams.dll
    Syntax
    public static class SourceOperations

    Methods

    | Edit this page View Source

    AggregateAsync<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, Task<TOut2>>)

    Similar to Aggregate<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, TOut2>) but with an asynchronous function. Applies the given function towards its current and next value, yielding the next current value.

    If the function fold returns a failure and the supervision decision is Restart current value starts at zero again the stream will continue.

    Emits when upstream completes

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels

    Aggregate<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, TOut2>)

    Declaration
    public static Source<TOut2, TMat> AggregateAsync<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, TOut2 zero, Func<TOut2, TOut1, Task<TOut2>> fold)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    TOut2 zero

    TBD

    Func<TOut2, TOut1, Task<TOut2>> fold

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    Aggregate<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, TOut2>)

    Similar to Scan<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, TOut2>) but only emits its result when the upstream completes, after which it also completes. Applies the given function fold towards its current and next value, yielding the next current value.

    If the function fold throws an exception and the supervision decision is Restart current value starts at zero again the stream will continue.

    Emits when upstream completes

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut2, TMat> Aggregate<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, TOut2 zero, Func<TOut2, TOut1, TOut2> fold)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    TOut2 zero

    TBD

    Func<TOut2, TOut1, TOut2> fold

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    AlsoToMaterialized<TOut, TMat, TMat2, TMat3>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat2>, Func<TMat, TMat2, TMat3>)

    Attaches the given Sink<TIn, TMat> to this IFlow<TOut, TMat>, meaning that elements that passes through will also be sent to the Sink<TIn, TMat>.

    @see AlsoTo<TOut, TMat>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat>)

    It is recommended to use the internally optimized Left<TLeft, TRight>(TLeft, TRight) and Right<TLeft, TRight>(TLeft, TRight) combiners where appropriate instead of manually writing functions that pass through one of the values.

    Declaration
    public static Source<TOut, TMat3> AlsoToMaterialized<TOut, TMat, TMat2, TMat3>(this Source<TOut, TMat> flow, IGraph<SinkShape<TOut>, TMat2> that, Func<TMat, TMat2, TMat3> materializerFunction)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SinkShape<TOut>, TMat2> that

    TBD

    Func<TMat, TMat2, TMat3> materializerFunction

    TBD

    Returns
    Type Description
    Source<TOut, TMat3>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    TMat2

    TBD

    TMat3

    TBD

    | Edit this page View Source

    AlsoToMaterialized<TOut, TMat, TMat2, TMat3>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat2>, Func<TMat, TMat2, TMat3>, bool)

    Attaches the given Sink<TIn, TMat> to this IFlow<TOut, TMat>, meaning that elements that passes through will also be sent to the Sink<TIn, TMat>.

    @see AlsoTo<TOut, TMat>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat>, bool)

    It is recommended to use the internally optimized Left<TLeft, TRight>(TLeft, TRight) and Right<TLeft, TRight>(TLeft, TRight) combiners where appropriate instead of manually writing functions that pass through one of the values.

    Declaration
    public static Source<TOut, TMat3> AlsoToMaterialized<TOut, TMat, TMat2, TMat3>(this Source<TOut, TMat> flow, IGraph<SinkShape<TOut>, TMat2> that, Func<TMat, TMat2, TMat3> materializerFunction, bool propagateFailure)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SinkShape<TOut>, TMat2> that

    TBD

    Func<TMat, TMat2, TMat3> materializerFunction

    TBD

    bool propagateFailure

    Propagate downstream failures and cancels parent stream

    Returns
    Type Description
    Source<TOut, TMat3>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    TMat2

    TBD

    TMat3

    TBD

    | Edit this page View Source

    AlsoTo<TOut, TMat>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat>)

    Attaches the given Sink<TIn, TMat> to this IFlow<TOut, TMat>, meaning that elements that passes through will also be sent to the Sink<TIn, TMat>.

    Emits when element is available and demand exists both from the Sink and the downstream.

    Backpressures when downstream or Sink backpressures

    Completes when upstream completes

    Cancels when downstream cancels

    Declaration
    public static Source<TOut, TMat> AlsoTo<TOut, TMat>(this Source<TOut, TMat> flow, IGraph<SinkShape<TOut>, TMat> that)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SinkShape<TOut>, TMat> that

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    AlsoTo<TOut, TMat>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat>, bool)

    Attaches the given Sink<TIn, TMat> to this IFlow<TOut, TMat>, meaning that elements that passes through will also be sent to the Sink<TIn, TMat>.

    Emits when element is available and demand exists both from the Sink and the downstream.

    Backpressures when downstream or Sink backpressures

    Completes when upstream completes

    Cancels when downstream cancels

    Declaration
    public static Source<TOut, TMat> AlsoTo<TOut, TMat>(this Source<TOut, TMat> flow, IGraph<SinkShape<TOut>, TMat> that, bool propagateFailure)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SinkShape<TOut>, TMat> that

    TBD

    bool propagateFailure

    Propagate downstream failures and cancels parent stream

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    AsSourceWithContext<TOut, TCtx, TMat>(Source<TOut, TMat>, Func<TOut, TCtx>)

    Starts a new kind of a source, that is able to keep a context object and propagate it across stages. Can be finished with AsSource().

    Declaration
    public static SourceWithContext<TOut, TCtx, TMat> AsSourceWithContext<TOut, TCtx, TMat>(this Source<TOut, TMat> flow, Func<TOut, TCtx> fn)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow
    Func<TOut, TCtx> fn

    Function used to extract context object out of the incoming events.

    Returns
    Type Description
    SourceWithContext<TOut, TCtx, TMat>
    Type Parameters
    Name Description
    TOut

    Type of produced events.

    TCtx

    Type of a context.

    TMat

    Type of materialized value.

    | Edit this page View Source

    BackpressureTimeout<TOut, TMat>(Source<TOut, TMat>, TimeSpan)

    If the time between the emission of an element and the following downstream demand exceeds the provided timeout, the stream is failed with a TimeoutException. The timeout is checked periodically, so the resolution of the check is one period (equals to timeout value).

    Emits when upstream emits an element

    Backpressures when downstream backpressures

    Completes when upstream completes or fails if timeout elapses between element emission and downstream demand.

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> BackpressureTimeout<TOut, TMat>(this Source<TOut, TMat> flow, TimeSpan timeout)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan timeout

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    BatchWeighted<TOut, TOut2, TMat>(Source<TOut, TMat>, long, Func<TOut, long>, Func<TOut, TOut2>, Func<TOut2, TOut, TOut2>)

    Allows a faster upstream to progress independently of a slower subscriber by aggregating elements into batches until the subscriber is ready to accept them.For example a batch step might concatenate ByteString elements up to the allowed max limit if the upstream publisher is faster.

    This element only rolls up elements if the upstream is faster, but if the downstream is faster it will not duplicate elements.

    Batching will apply for all elements, even if a single element cost is greater than the total allowed limit. In this case, previous batched elements will be emitted, then the "heavy" element will be emitted (after being applied with the seed function) without batching further elements with it, and then the rest of the incoming elements are batched.

    Emits when downstream stops backpressuring and there is a batched element available

    Backpressures when there are max weighted batched elements + 1 pending element and downstream backpressures

    Completes when upstream completes and there is no batched/pending element waiting

    Cancels when downstream cancels

    See also ConflateWithSeed<TOut, TMat, TSeed>(Source<TOut, TMat>, Func<TOut, TSeed>, Func<TSeed, TOut, TSeed>), Batch<TOut, TOut2, TMat>(Source<TOut, TMat>, long, Func<TOut, TOut2>, Func<TOut2, TOut, TOut2>)

    Declaration
    public static Source<TOut2, TMat> BatchWeighted<TOut, TOut2, TMat>(this Source<TOut, TMat> flow, long max, Func<TOut, long> costFunction, Func<TOut, TOut2> seed, Func<TOut2, TOut, TOut2> aggregate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    long max

    maximum weight of elements to batch before backpressuring upstream (must be positive non-zero)

    Func<TOut, long> costFunction

    a function to compute a single element weight

    Func<TOut, TOut2> seed

    Provides the first state for a batched value using the first unconsumed element as a start

    Func<TOut2, TOut, TOut2> aggregate

    Takes the currently batched value and the current pending element to produce a new aggregate

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    Batch<TOut, TOut2, TMat>(Source<TOut, TMat>, long, Func<TOut, TOut2>, Func<TOut2, TOut, TOut2>)

    Allows a faster upstream to progress independently of a slower subscriber by aggregating elements into batches until the subscriber is ready to accept them.For example a batch step might store received elements in an array up to the allowed max limit if the upstream publisher is faster.

    This only rolls up elements if the upstream is faster, but if the downstream is faster it will not duplicate elements.

    Emits when downstream stops backpressuring and there is an aggregated element available

    Backpressures when there are max batched elements and 1 pending element and downstream backpressures

    Completes when upstream completes and there is no batched/pending element waiting

    Cancels when downstream cancels

    See also ConflateWithSeed<TOut, TMat, TSeed>(Source<TOut, TMat>, Func<TOut, TSeed>, Func<TSeed, TOut, TSeed>), BatchWeighted<TOut, TOut2, TMat>(Source<TOut, TMat>, long, Func<TOut, long>, Func<TOut, TOut2>, Func<TOut2, TOut, TOut2>)

    Declaration
    public static Source<TOut2, TMat> Batch<TOut, TOut2, TMat>(this Source<TOut, TMat> flow, long max, Func<TOut, TOut2> seed, Func<TOut2, TOut, TOut2> aggregate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    long max

    maximum number of elements to batch before backpressuring upstream (must be positive non-zero)

    Func<TOut, TOut2> seed

    Provides the first state for a batched value using the first unconsumed element as a start

    Func<TOut2, TOut, TOut2> aggregate

    Takes the currently batched value and the current pending element to produce a new aggregate

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    Buffer<TOut, TMat>(Source<TOut, TMat>, int, OverflowStrategy)

    Adds a fixed size buffer in the flow that allows to store elements from a faster upstream until it becomes full. Depending on the defined OverflowStrategy it might drop elements or backpressure the upstream if there is no space available

    Emits when downstream stops backpressuring and there is a pending element in the buffer

    Backpressures when downstream backpressures or depending on OverflowStrategy:

    * Backpressure - backpressures when buffer is full

    * DropHead, DropTail, DropBuffer - never backpressures

    * Fail - fails the stream if buffer gets full

    Completes when upstream completes and buffered elements has been drained

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Buffer<TOut, TMat>(this Source<TOut, TMat> flow, int size, OverflowStrategy strategy)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    int size

    The size of the buffer in element count

    OverflowStrategy strategy

    Strategy that is used when incoming elements cannot fit inside the buffer

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Collect<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<TOut1, bool>, Func<TOut1, TOut2>)

    Transform this stream by applying the given function collector to each of the elements on which the function is defined (read: isDefined returns true) as they pass through this processing step. Non-matching elements are filtered out.

    Emits when the provided function collector is defined for the element

    Backpressures when the function collector is defined for the element and downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut2, TMat> Collect<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, Func<TOut1, bool> isDefined, Func<TOut1, TOut2> collector)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow
    Func<TOut1, bool> isDefined
    Func<TOut1, TOut2> collector
    Returns
    Type Description
    Source<TOut2, TMat>
    Type Parameters
    Name Description
    TOut1
    TOut2
    TMat
    | Edit this page View Source

    Collect<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<TOut1, TOut2>)

    Transform this stream by applying the given function collector to each of the elements on which the function is defined (read: returns not null) as they pass through this processing step. Non-matching elements are filtered out.

    Emits when the provided function collector is defined for the element

    Backpressures when the function collector is defined for the element and downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    [Obsolete("Deprecated. Please use Collect(isDefined, collector) instead")]
    public static Source<TOut2, TMat> Collect<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, Func<TOut1, TOut2> collector)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow
    Func<TOut1, TOut2> collector
    Returns
    Type Description
    Source<TOut2, TMat>
    Type Parameters
    Name Description
    TOut1
    TOut2
    TMat
    | Edit this page View Source

    CombineMaterialized<T, TOut2, TMat1, TMat2, TMatOut>(Source<T, TMat1>, Source<T, TMat2>, Func<int, IGraph<UniformFanInShape<T, TOut2>, NotUsed>>, Func<TMat1, TMat2, TMatOut>)

    Combines the given Source<TOut, TMat> to this Source<TOut, TMat> with fan-in strategy like Merge<TIn, TOut> or Concat<TOut, TMat>(Source<TOut, TMat>, IGraph<SourceShape<TOut>, TMat>) and returns Source<TOut, TMat> with a materialized value.

    Declaration
    public static Source<TOut2, TMatOut> CombineMaterialized<T, TOut2, TMat1, TMat2, TMatOut>(this Source<T, TMat1> flow, Source<T, TMat2> other, Func<int, IGraph<UniformFanInShape<T, TOut2>, NotUsed>> strategy, Func<TMat1, TMat2, TMatOut> combineMaterializers)
    Parameters
    Type Name Description
    Source<T, TMat1> flow

    TBD

    Source<T, TMat2> other

    TBD

    Func<int, IGraph<UniformFanInShape<T, TOut2>, NotUsed>> strategy

    TBD

    Func<TMat1, TMat2, TMatOut> combineMaterializers

    TBD

    Returns
    Type Description
    Source<TOut2, TMatOut>

    TBD

    Type Parameters
    Name Description
    T

    TBD

    TOut2

    TBD

    TMat1

    TBD

    TMat2

    TBD

    TMatOut

    TBD

    | Edit this page View Source

    CompletionTimeout<TOut, TMat>(Source<TOut, TMat>, TimeSpan)

    If the completion of the stream does not happen until the provided timeout, the stream is failed with a TimeoutException.

    Emits when upstream emits an element

    Backpressures when downstream backpressures

    Completes when upstream completes or fails if timeout elapses before upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> CompletionTimeout<TOut, TMat>(this Source<TOut, TMat> flow, TimeSpan timeout)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan timeout

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    ConcatMany<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<TOut1, IGraph<SourceShape<TOut2>, TMat>>)

    Transform each input element into a Source<TOut, TMat> of output elements that is then flattened into the output stream by concatenation, fully consuming one Source after the other.

    Emits when a currently consumed substream has an element available

    Backpressures when downstream backpressures

    Completes when upstream completes and all consumed substreams complete

    Cancels when downstream cancels
    Declaration
    public static Source<TOut2, TMat> ConcatMany<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, Func<TOut1, IGraph<SourceShape<TOut2>, TMat>> flatten)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    Func<TOut1, IGraph<SourceShape<TOut2>, TMat>> flatten

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    Concat<TOut, TMat>(Source<TOut, TMat>, IGraph<SourceShape<TOut>, TMat>)

    Concatenate the given Source<TOut, TMat> to this IFlow<TOut, TMat>, meaning that once this Flow’s input is exhausted and all result elements have been generated, the Source’s elements will be produced.

    Note that the Source<TOut, TMat> is materialized together with this IFlow<TOut, TMat> and just kept from producing elements by asserting back-pressure until its time comes.

    If this IFlow<TOut, TMat> gets upstream error - no elements from the given Source<TOut, TMat> will be pulled.

    Emits when element is available from current stream or from the given Source<TOut, TMat> when current is completed

    Backpressures when downstream backpressures

    Completes when given Source<TOut, TMat> completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Concat<TOut, TMat>(this Source<TOut, TMat> flow, IGraph<SourceShape<TOut>, TMat> other)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SourceShape<TOut>, TMat> other

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    ConflateWithSeed<TOut, TMat, TSeed>(Source<TOut, TMat>, Func<TOut, TSeed>, Func<TSeed, TOut, TSeed>)

    Allows a faster upstream to progress independently of a slower subscriber by conflating elements into a summary until the subscriber is ready to accept them. For example a conflate step might average incoming numbers if the upstream publisher is faster.

    This version of conflate allows to derive a seed from the first element and change the aggregated type to be different than the input type. See Conflate<TOut, TMat>(Source<TOut, TMat>, Func<TOut, TOut, TOut>) for a simpler version that does not change types.

    This element only rolls up elements if the upstream is faster, but if the downstream is faster it will not duplicate elements.

    Emits when downstream stops backpressuring and there is a conflated element available

    Backpressures when never

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TSeed, TMat> ConflateWithSeed<TOut, TMat, TSeed>(this Source<TOut, TMat> flow, Func<TOut, TSeed> seed, Func<TSeed, TOut, TSeed> aggregate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<TOut, TSeed> seed

    Provides the first state for a conflated value using the first unconsumed element as a start

    Func<TSeed, TOut, TSeed> aggregate

    Takes the currently aggregated value and the current pending element to produce a new aggregate

    Returns
    Type Description
    Source<TSeed, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    TSeed

    TBD

    | Edit this page View Source

    Conflate<TOut, TMat>(Source<TOut, TMat>, Func<TOut, TOut, TOut>)

    Allows a faster upstream to progress independently of a slower subscriber by conflating elements into a summary until the subscriber is ready to accept them. For example a conflate step might average incoming numbers if the upstream publisher is faster.

    This version of conflate does not change the output type of the stream. See ConflateWithSeed<TOut, TMat, TSeed>(Source<TOut, TMat>, Func<TOut, TSeed>, Func<TSeed, TOut, TSeed>) for a more flexible version that can take a seed function and transform elements while rolling up.

    This element only rolls up elements if the upstream is faster, but if the downstream is faster it will not duplicate elements.

    Emits when downstream stops backpressuring and there is a conflated element available

    Backpressures when never

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Conflate<TOut, TMat>(this Source<TOut, TMat> flow, Func<TOut, TOut, TOut> aggregate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<TOut, TOut, TOut> aggregate

    Takes the currently aggregated value and the current pending element to produce a new aggregate

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Delay<TOut, TMat>(Source<TOut, TMat>, TimeSpan, DelayOverflowStrategy?)

    Shifts elements emission in time by a specified amount. It allows to store elements in internal buffer while waiting for next element to be emitted. Depending on the defined DelayOverflowStrategy it might drop elements or backpressure the upstream if there is no space available in the buffer.

    Delay precision is 10ms to avoid unnecessary timer scheduling cycles

    Internal buffer has default capacity 16. You can set buffer size by calling CreateInputBuffer(int, int)

    Emits when there is a pending element in the buffer and configured time for this element elapsed

    * EmitEarly - strategy do not wait to emit element if buffer is full Backpressures when depending on OverflowStrategy

    * Backpressure - backpressures when buffer is full

    * DropHead, DropTail, DropBuffer - never backpressures

    * Fail - fails the stream if buffer gets full

    Completes when upstream completes and buffered elements has been drained

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Delay<TOut, TMat>(this Source<TOut, TMat> flow, TimeSpan of, DelayOverflowStrategy? strategy = null)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan of

    Time to shift all messages.

    DelayOverflowStrategy? strategy

    Strategy that is used when incoming elements cannot fit inside the buffer

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Detach<TOut, TMat>(Source<TOut, TMat>)

    Detaches upstream demand from downstream demand without detaching the stream rates; in other words acts like a buffer of size 1.

    Emits when upstream emits an element

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels

    Declaration
    public static Source<TOut, TMat> Detach<TOut, TMat>(this Source<TOut, TMat> flow)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    DivertToMaterialized<TOut, TMat, TMat2, TMat3>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat2>, Func<TOut, bool>, Func<TMat, TMat2, TMat3>)

    Attaches the given Sink<TIn, TMat> to this IFlow<TOut, TMat>, meaning that elements will be sent to the Sink<TIn, TMat> instead of being passed through if the predicate when returns true.

    @see DivertTo<TOut, TMat>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat>, Func<TOut, bool>)

    It is recommended to use the internally optimized Left<TLeft, TRight>(TLeft, TRight) and Right<TLeft, TRight>(TLeft, TRight) combiners where appropriate instead of manually writing functions that pass through one of the values.

    Declaration
    public static Source<TOut, TMat3> DivertToMaterialized<TOut, TMat, TMat2, TMat3>(this Source<TOut, TMat> flow, IGraph<SinkShape<TOut>, TMat2> that, Func<TOut, bool> when, Func<TMat, TMat2, TMat3> materializerFunction)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SinkShape<TOut>, TMat2> that

    TBD

    Func<TOut, bool> when

    TBD

    Func<TMat, TMat2, TMat3> materializerFunction

    TBD

    Returns
    Type Description
    Source<TOut, TMat3>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    TMat2

    TBD

    TMat3

    TBD

    | Edit this page View Source

    DivertTo<TOut, TMat>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat>, Func<TOut, bool>)

    Attaches the given Sink<TIn, TMat> to this IFlow<TOut, TMat>, meaning that elements will be sent to the Sink<TIn, TMat> instead of being passed through if the predicate when returns true.

    Emits when an element is available from the input and the chosen output has demand

    Backpressures when the currently chosen output back-pressures

    Completes when upstream completes and no output is pending

    Cancels when when all downstreams cancel

    Declaration
    public static Source<TOut, TMat> DivertTo<TOut, TMat>(this Source<TOut, TMat> flow, IGraph<SinkShape<TOut>, TMat> that, Func<TOut, bool> when)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SinkShape<TOut>, TMat> that

    TBD

    Func<TOut, bool> when

    TBD

    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Expand<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<TOut1, IEnumerator<TOut2>>)

    Allows a faster downstream to progress independently of a slower publisher by extrapolating elements from an older element until new element comes from the upstream. For example an expand step might repeat the last element for the subscriber until it receives an update from upstream.

    This element will never "drop" upstream elements as all elements go through at least one extrapolation step. This means that if the upstream is actually faster than the upstream it will be backpressured by the downstream subscriber.

    Expand does not support Restart and Resume. Exceptions from the extrapolate function will complete the stream with failure.

    Emits when downstream stops backpressuring

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut2, TMat> Expand<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, Func<TOut1, IEnumerator<TOut2>> extrapolate)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    Func<TOut1, IEnumerator<TOut2>> extrapolate

    Takes the current extrapolation state to produce an output element and the next extrapolation state.

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    GroupBy<TOut, TMat, TKey>(Source<TOut, TMat>, Func<TOut, TKey>)

    This operation demultiplexes the incoming stream into separate output streams, one for each element key. The key is computed for each element using the given function. When a new key is encountered for the first time it is emitted to the downstream subscriber together with a fresh flow that will eventually produce all the elements of the substream for that key. Not consuming the elements from the created streams will stop this processor from processing more elements, therefore you must take care to unblock (or cancel) all of the produced streams even if you want to consume only one of them.

    If the group by function groupingFunc throws an exception and the supervision decision is Stop the stream and substreams will be completed with failure.

    If the group by groupingFunc throws an exception and the supervision decision is Resume or Restart the element is dropped and the stream and substreams continue.

    Emits when an element for which the grouping function returns a group that has not yet been created. Emits the new group

    Backpressures when there is an element pending for a group whose substream backpressures

    Completes when upstream completes

    Cancels when downstream cancels and all substreams cancel
    Declaration
    public static SubFlow<TOut, TMat, IRunnableGraph<TMat>> GroupBy<TOut, TMat, TKey>(this Source<TOut, TMat> flow, Func<TOut, TKey> groupingFunc)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<TOut, TKey> groupingFunc

    Computes the key for each element

    Returns
    Type Description
    SubFlow<TOut, TMat, IRunnableGraph<TMat>>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    TKey

    TBD

    | Edit this page View Source

    GroupBy<TOut, TMat, TKey>(Source<TOut, TMat>, int, Func<TOut, TKey>)

    This operation demultiplexes the incoming stream into separate output streams, one for each element key. The key is computed for each element using the given function. When a new key is encountered for the first time it is emitted to the downstream subscriber together with a fresh flow that will eventually produce all the elements of the substream for that key. Not consuming the elements from the created streams will stop this processor from processing more elements, therefore you must take care to unblock (or cancel) all of the produced streams even if you want to consume only one of them.

    If the group by function groupingFunc throws an exception and the supervision decision is Stop the stream and substreams will be completed with failure.

    If the group by groupingFunc throws an exception and the supervision decision is Resume or Restart the element is dropped and the stream and substreams continue.

    Emits when an element for which the grouping function returns a group that has not yet been created. Emits the new group

    Backpressures when there is an element pending for a group whose substream backpressures

    Completes when upstream completes

    Cancels when downstream cancels and all substreams cancel
    Declaration
    public static SubFlow<TOut, TMat, IRunnableGraph<TMat>> GroupBy<TOut, TMat, TKey>(this Source<TOut, TMat> flow, int maxSubstreams, Func<TOut, TKey> groupingFunc)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    int maxSubstreams

    Configures the maximum number of substreams (keys) that are supported; if more distinct keys are encountered then the stream fails. Set to -1 for infinite substreams.

    Func<TOut, TKey> groupingFunc

    Computes the key for each element

    Returns
    Type Description
    SubFlow<TOut, TMat, IRunnableGraph<TMat>>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    TKey

    TBD

    | Edit this page View Source

    GroupedWeightedWithin<TOut, TMat>(Source<TOut, TMat>, long, int, TimeSpan, Func<TOut, long>)

    Chunk up this stream into groups of elements received within a time window, or limited by the weight and number of the elements, whatever happens first. Empty groups will not be emitted if no elements are received from upstream. The last group before end-of-stream will contain the buffered elements since the previously emitted group.

    maxWeight must be positive, maxNumber must be positive, and interval must be greater than 0 seconds, otherwise ArgumentException is thrown.

    Emits when the configured time elapses since the last group has been emitted or weight limit reached

    Backpressures when downstream backpressures, and buffered group(+ pending element) weighs more than `maxWeight` or has more than `maxNumber` elements

    Completes when upstream completes(emits last group)

    Cancels when downstream completes

    Declaration
    public static Source<IEnumerable<TOut>, TMat> GroupedWeightedWithin<TOut, TMat>(this Source<TOut, TMat> flow, long maxWeight, int maxNumber, TimeSpan interval, Func<TOut, long> costFn)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    long maxWeight

    TBD

    int maxNumber

    TBD

    TimeSpan interval

    TBD

    Func<TOut, long> costFn

    TBD

    Returns
    Type Description
    Source<IEnumerable<TOut>, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    GroupedWeightedWithin<TOut, TMat>(Source<TOut, TMat>, long, TimeSpan, Func<TOut, long>)

    Chunk up this stream into groups of elements received within a time window, or limited by the weight of the elements, whatever happens first. Empty groups will not be emitted if no elements are received from upstream. The last group before end-of-stream will contain the buffered elements since the previously emitted group.

    maxWeight must be positive, and interval must be greater than 0 seconds, otherwise ArgumentException is thrown.

    Emits when the configured time elapses since the last group has been emitted or weight limit reached

    Backpressures when downstream backpressures, and buffered group(+ pending element) weighs more than `maxWeight`

    Completes when upstream completes(emits last group)

    Cancels when downstream completes

    Declaration
    public static Source<IEnumerable<TOut>, TMat> GroupedWeightedWithin<TOut, TMat>(this Source<TOut, TMat> flow, long maxWeight, TimeSpan interval, Func<TOut, long> costFn)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    long maxWeight

    TBD

    TimeSpan interval

    TBD

    Func<TOut, long> costFn

    TBD

    Returns
    Type Description
    Source<IEnumerable<TOut>, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    GroupedWithin<TOut, TMat>(Source<TOut, TMat>, int, TimeSpan)

    Chunk up this stream into groups of elements received within a time window, or limited by the given number of elements, whatever happens first. Empty groups will not be emitted if no elements are received from upstream. The last group before end-of-stream will contain the buffered elements since the previously emitted group.

    n must be positive, and timeout must be greater than 0 seconds, otherwise ArgumentException is thrown.

    Emits when the configured time elapses since the last group has been emitted

    Backpressures when the configured time elapses since the last group has been emitted

    Completes when upstream completes (emits last group)

    Cancels when downstream completes
    Declaration
    public static Source<IEnumerable<TOut>, TMat> GroupedWithin<TOut, TMat>(this Source<TOut, TMat> flow, int n, TimeSpan timeout)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    int n

    TBD

    TimeSpan timeout

    TBD

    Returns
    Type Description
    Source<IEnumerable<TOut>, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    Exceptions
    Type Condition
    ArgumentException

    Thrown if n is less than or equal zero or timeout is Zero.

    | Edit this page View Source

    Grouped<TOut, TMat>(Source<TOut, TMat>, int)

    Chunk up this stream into groups of the given size, with the last group possibly smaller than requested due to end-of-stream. n must be positive, otherwise ArgumentException is thrown.

    Emits when the specified number of elements has been accumulated or upstream completed

    Backpressures when a group has been assembled and downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<IEnumerable<TOut>, TMat> Grouped<TOut, TMat>(this Source<TOut, TMat> flow, int n)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    int n

    TBD

    Returns
    Type Description
    Source<IEnumerable<TOut>, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    Exceptions
    Type Condition
    ArgumentException

    Thrown, if n is less than or equal zero.

    | Edit this page View Source

    IdleTimeout<TOut, TMat>(Source<TOut, TMat>, TimeSpan)

    If the time between two processed elements exceed the provided timeout, the stream is failed with a TimeoutException. The timeout is checked periodically, so the resolution of the check is one period (equals to timeout value).

    Emits when upstream emits an element

    Backpressures when downstream backpressures

    Completes when upstream completes or fails if timeout elapses between two emitted elements

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> IdleTimeout<TOut, TMat>(this Source<TOut, TMat> flow, TimeSpan timeout)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan timeout

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    InitialDelay<TOut, TMat>(Source<TOut, TMat>, TimeSpan)

    Delays the initial element by the specified duration.

    Emits when upstream emits an element if the initial delay is already elapsed

    Backpressures when downstream backpressures or initial delay is not yet elapsed

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> InitialDelay<TOut, TMat>(this Source<TOut, TMat> flow, TimeSpan delay)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan delay

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    InitialTimeout<TOut, TMat>(Source<TOut, TMat>, TimeSpan)

    If the first element has not passed through this stage before the provided timeout, the stream is failed with a TimeoutException.

    Emits when upstream emits an element

    Backpressures when downstream backpressures

    Completes when upstream completes or fails if timeout elapses before first element arrives

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> InitialTimeout<TOut, TMat>(this Source<TOut, TMat> flow, TimeSpan timeout)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan timeout

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    InterleaveMaterialized<T1, T2, TMat, TMat2, TMat3>(Source<T1, TMat>, IGraph<SourceShape<T2>, TMat2>, int, Func<TMat, TMat2, TMat3>)

    Interleave is a deterministic merge of the given Source<TOut, TMat> with elements of this IFlow<TOut, TMat>. It first emits segmentSize number of elements from this flow to downstream, then - same amount for graph source, then repeat process.

    After one of upstreams is complete than all the rest elements will be emitted from the second one

    If it gets error from one of upstreams - stream completes with failure.

    @seeInterleave<TIn, TOut>.

    It is recommended to use the internally optimized Left<TLeft, TRight>(TLeft, TRight) and Right<TLeft, TRight>(TLeft, TRight) combiners where appropriate instead of manually writing functions that pass through one of the values.

    Declaration
    public static Source<T2, TMat3> InterleaveMaterialized<T1, T2, TMat, TMat2, TMat3>(this Source<T1, TMat> flow, IGraph<SourceShape<T2>, TMat2> graph, int segmentSize, Func<TMat, TMat2, TMat3> combine) where T1 : T2
    Parameters
    Type Name Description
    Source<T1, TMat> flow

    TBD

    IGraph<SourceShape<T2>, TMat2> graph

    TBD

    int segmentSize

    TBD

    Func<TMat, TMat2, TMat3> combine

    TBD

    Returns
    Type Description
    Source<T2, TMat3>

    TBD

    Type Parameters
    Name Description
    T1

    TBD

    T2

    TBD

    TMat

    TBD

    TMat2

    TBD

    TMat3

    TBD

    | Edit this page View Source

    Interleave<T1, T2, TMat>(Source<T1, TMat>, IGraph<SourceShape<T2>, TMat>, int)

    Interleave is a deterministic merge of the given Source<TOut, TMat> with elements of this IFlow<TOut, TMat>. It first emits segmentSize number of elements from this flow to downstream, then - same amount for other source, then repeat process.

    After one of upstreams is complete than all the rest elements will be emitted from the second one

    If it gets error from one of upstreams - stream completes with failure.

    Emits when element is available from the currently consumed upstream

    Backpressures when downstream backpressures. Signal to current upstream, switch to next upstream when received segmentSize elements

    Completes when the IFlow<TOut, TMat> and given Source<TOut, TMat> completes

    Cancels when downstream cancels
    Declaration
    public static Source<T2, TMat> Interleave<T1, T2, TMat>(this Source<T1, TMat> flow, IGraph<SourceShape<T2>, TMat> other, int segmentSize) where T1 : T2
    Parameters
    Type Name Description
    Source<T1, TMat> flow

    TBD

    IGraph<SourceShape<T2>, TMat> other

    TBD

    int segmentSize

    TBD

    Returns
    Type Description
    Source<T2, TMat>

    TBD

    Type Parameters
    Name Description
    T1

    TBD

    T2

    TBD

    TMat

    TBD

    Examples
    Source(List(1, 2, 3)).Interleave(List(4, 5, 6, 7), 2) // 1, 2, 4, 5, 3, 6, 7
    | Edit this page View Source

    Intersperse<TOut, TMat>(Source<TOut, TMat>, TOut)

    Intersperses stream with provided element, similar to how Join(string, params string[]) injects a separator between a collection's elements.

    Additionally can inject start and end marker elements to stream.

    In case you want to only prepend or only append an element (yet still use the intercept feature to inject a separator between elements, you may want to use the following pattern instead of the 3-argument version of intersperse (See Concat<TOut, TMat>(Source<TOut, TMat>, IGraph<SourceShape<TOut>, TMat>) for semantics details).

    Emits when upstream emits (or before with the inject element if provided)

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Intersperse<TOut, TMat>(this Source<TOut, TMat> flow, TOut inject)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TOut inject

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when inject is undefined.

    | Edit this page View Source

    Intersperse<TOut, TMat>(Source<TOut, TMat>, TOut, TOut, TOut)

    Intersperses stream with provided element, similar to how Join(string, params string[]) injects a separator between a collection's elements.

    Additionally can inject start and end marker elements to stream.

    In case you want to only prepend or only append an element (yet still use the intercept feature to inject a separator between elements, you may want to use the following pattern instead of the 3-argument version of intersperse (See Concat<TOut, TMat>(Source<TOut, TMat>, IGraph<SourceShape<TOut>, TMat>) for semantics details).

    Emits when upstream emits (or before with the start element if provided)

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Intersperse<TOut, TMat>(this Source<TOut, TMat> flow, TOut start, TOut inject, TOut end)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TOut start

    TBD

    TOut inject

    TBD

    TOut end

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when any of the start, inject or end is undefined.

    | Edit this page View Source

    KeepAlive<TOut, TInjected, TMat>(Source<TOut, TMat>, TimeSpan, Func<TInjected>)

    Injects additional elements if the upstream does not emit for a configured amount of time. In other words, this stage attempts to maintains a base rate of emitted elements towards the downstream.

    If the downstream backpressures then no element is injected until downstream demand arrives. Injected elements do not accumulate during this period.

    Upstream elements are always preferred over injected elements.

    Emits when upstream emits an element or if the upstream was idle for the configured period

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TInjected, TMat> KeepAlive<TOut, TInjected, TMat>(this Source<TOut, TMat> flow, TimeSpan timeout, Func<TInjected> injectElement) where TOut : TInjected
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan timeout

    TBD

    Func<TInjected> injectElement

    TBD

    Returns
    Type Description
    Source<TInjected, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TInjected

    TBD

    TMat

    TBD

    | Edit this page View Source

    LimitWeighted<T, TMat>(Source<T, TMat>, long, Func<T, long>)

    Ensure stream boundedness by evaluating the cost of incoming elements using a cost function. Exactly how many elements will be allowed to travel downstream depends on the evaluated cost of each element. If the accumulated cost exceeds max, it will signal upstream failure StreamLimitReachedException downstream.

    Due to input buffering some elements may have been requested from upstream publishers that will then not be processed downstream of this step.

    The stream will be completed without producing any elements if max is zero or negative.

    Emits when the specified number of elements to take has not yet been reached

    Backpressures when downstream backpressures

    Completes when the defined number of elements has been taken or upstream completes

    Cancels when the defined number of elements has been taken or downstream cancels
    Declaration
    public static Source<T, TMat> LimitWeighted<T, TMat>(this Source<T, TMat> flow, long max, Func<T, long> costFunc)
    Parameters
    Type Name Description
    Source<T, TMat> flow

    TBD

    long max

    TBD

    Func<T, long> costFunc

    TBD

    Returns
    Type Description
    Source<T, TMat>

    TBD

    Type Parameters
    Name Description
    T

    TBD

    TMat

    TBD

    See Also
    Take<TOut, TMat>(Source<TOut, TMat>, long)
    TakeWithin<TOut, TMat>(Source<TOut, TMat>, TimeSpan)
    TakeWhile<TOut, TMat>(Source<TOut, TMat>, Predicate<TOut>, bool)
    | Edit this page View Source

    Limit<T, TMat>(Source<T, TMat>, long)

    Ensure stream boundedness by limiting the number of elements from upstream. If the number of incoming elements exceeds max, it will signal upstream failure StreamLimitReachedException downstream.

    Due to input buffering some elements may have been requested from upstream publishers that will then not be processed downstream of this step.

    The stream will be completed without producing any elements if max is zero or negative.

    Emits when the specified number of elements to take has not yet been reached

    Backpressures when downstream backpressures

    Completes when the defined number of elements has been taken or upstream completes

    Cancels when the defined number of elements has been taken or downstream cancels
    Declaration
    public static Source<T, TMat> Limit<T, TMat>(this Source<T, TMat> flow, long max)
    Parameters
    Type Name Description
    Source<T, TMat> flow

    TBD

    long max

    TBD

    Returns
    Type Description
    Source<T, TMat>

    TBD

    Type Parameters
    Name Description
    T

    TBD

    TMat

    TBD

    See Also
    Take<TOut, TMat>(Source<TOut, TMat>, long)
    TakeWithin<TOut, TMat>(Source<TOut, TMat>, TimeSpan)
    TakeWhile<TOut, TMat>(Source<TOut, TMat>, Predicate<TOut>, bool)
    | Edit this page View Source

    Log<TOut, TMat>(Source<TOut, TMat>, string, Func<TOut, object>, ILoggingAdapter, LogLevel)

    Logs elements flowing through the stream as well as completion and erroring.

    By default element and completion signals are logged on debug level, and errors are logged on Error level. This can be adjusted according to your needs by providing a custom Attributes.LogLevels attribute on the given Flow.

    Emits when the mapping function returns an element

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Log<TOut, TMat>(this Source<TOut, TMat> flow, string name, Func<TOut, object> extract = null, ILoggingAdapter log = null, LogLevel logLevel = LogLevel.DebugLevel)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    The underlying graph

    string name

    The name of the LogSource

    Func<TOut, object> extract

    Optional. Extract the content that will be captured by the logger

    ILoggingAdapter log

    Optional. Use an external logging adapter

    LogLevel logLevel

    Optional. The log level being logged. Defaults to DebugLevel

    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TOut

    The output type

    TMat

    The materialized type

    | Edit this page View Source

    MergeMany<TOut1, TOut2, TMat>(Source<TOut1, TMat>, int, Func<TOut1, IGraph<SourceShape<TOut2>, TMat>>)

    Transform each input element into a Source<TOut, TMat> of output elements that is then flattened into the output stream by merging, where at most breadth substreams are being consumed at any given time.

    Emits when a currently consumed substream has an element available

    Backpressures when downstream backpressures

    Completes when upstream completes and all consumed substreams complete

    Cancels when downstream cancels
    Declaration
    public static Source<TOut2, TMat> MergeMany<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, int breadth, Func<TOut1, IGraph<SourceShape<TOut2>, TMat>> flatten)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    int breadth

    TBD

    Func<TOut1, IGraph<SourceShape<TOut2>, TMat>> flatten

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    MergeMaterialized<TOut1, TOut2, TMat, TMat2, TMat3>(Source<TOut1, TMat>, IGraph<SourceShape<TOut2>, TMat2>, Func<TMat, TMat2, TMat3>)

    Merge the given Source<TOut, TMat> to this IFlow<TOut, TMat>, taking elements as they arrive from input streams, picking randomly when several elements ready.

    @see Merge<TOut1, TOut2, TMat>(Source<TOut1, TMat>, IGraph<SourceShape<TOut2>, TMat>, bool)

    It is recommended to use the internally optimized Left<TLeft, TRight>(TLeft, TRight) and Right<TLeft, TRight>(TLeft, TRight) combiners where appropriate instead of manually writing functions that pass through one of the values.

    Declaration
    public static Source<TOut2, TMat3> MergeMaterialized<TOut1, TOut2, TMat, TMat2, TMat3>(this Source<TOut1, TMat> flow, IGraph<SourceShape<TOut2>, TMat2> that, Func<TMat, TMat2, TMat3> combine) where TOut1 : TOut2
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    IGraph<SourceShape<TOut2>, TMat2> that

    TBD

    Func<TMat, TMat2, TMat3> combine

    TBD

    Returns
    Type Description
    Source<TOut2, TMat3>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    TMat2

    TBD

    TMat3

    TBD

    | Edit this page View Source

    MergeSorted<TOut, TMat>(Source<TOut, TMat>, IGraph<SourceShape<TOut>, TMat>)

    Merge the given Source<TOut, TMat> to this IFlow<TOut, TMat>, taking elements as they arrive from input streams, picking always the smallest of the available elements(waiting for one element from each side to be available). This means that possible contiguity of the input streams is not exploited to avoid waiting for elements, this merge will block when one of the inputs does not have more elements(and does not complete).

    Emits when one of the inputs has an element available

    Backpressures when downstream backpressures

    Completes when all upstreams complete

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> MergeSorted<TOut, TMat>(this Source<TOut, TMat> flow, IGraph<SourceShape<TOut>, TMat> other) where TOut : IComparable<TOut>
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SourceShape<TOut>, TMat> other

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    MergeSorted<TOut, TMat>(Source<TOut, TMat>, IGraph<SourceShape<TOut>, TMat>, IComparer<TOut>)

    Merge the given Source<TOut, TMat> to this IFlow<TOut, TMat>, taking elements as they arrive from input streams, picking always the smallest of the available elements(waiting for one element from each side to be available). This means that possible contiguity of the input streams is not exploited to avoid waiting for elements, this merge will block when one of the inputs does not have more elements(and does not complete).

    Emits when one of the inputs has an element available

    Backpressures when downstream backpressures

    Completes when all upstreams complete

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> MergeSorted<TOut, TMat>(this Source<TOut, TMat> flow, IGraph<SourceShape<TOut>, TMat> other, IComparer<TOut> comparer)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SourceShape<TOut>, TMat> other

    TBD

    IComparer<TOut> comparer

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    MergeSorted<TOut, TMat>(Source<TOut, TMat>, IGraph<SourceShape<TOut>, TMat>, Func<TOut, TOut, int>)

    Merge the given Source<TOut, TMat> to this IFlow<TOut, TMat>, taking elements as they arrive from input streams, picking always the smallest of the available elements(waiting for one element from each side to be available). This means that possible contiguity of the input streams is not exploited to avoid waiting for elements, this merge will block when one of the inputs does not have more elements(and does not complete).

    Emits when one of the inputs has an element available

    Backpressures when downstream backpressures

    Completes when all upstreams complete

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> MergeSorted<TOut, TMat>(this Source<TOut, TMat> flow, IGraph<SourceShape<TOut>, TMat> other, Func<TOut, TOut, int> orderFunc)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    IGraph<SourceShape<TOut>, TMat> other

    TBD

    Func<TOut, TOut, int> orderFunc

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Merge<TOut1, TOut2, TMat>(Source<TOut1, TMat>, IGraph<SourceShape<TOut2>, TMat>, bool)

    Merge the given Source<TOut, TMat> to this IFlow<TOut, TMat>, taking elements as they arrive from input streams, picking randomly when several elements ready.

    Emits when one of the inputs has an element available

    Backpressures when downstream backpressures

    Completes when all upstreams complete

    Cancels when downstream cancels
    Declaration
    public static Source<TOut2, TMat> Merge<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, IGraph<SourceShape<TOut2>, TMat> other, bool eagerComplete = false) where TOut1 : TOut2
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    IGraph<SourceShape<TOut2>, TMat> other

    TBD

    bool eagerComplete

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    Monitor<TOut, TMat, TMat2>(Source<TOut, TMat>, Func<TMat, IFlowMonitor, TMat2>)

    Materializes to IFlowMonitor that allows monitoring of the the current flow. All events are propagated by the monitor unchanged. Note that the monitor inserts a memory barrier every time it processes an event, and may therefor affect performance. The combine function is used to combine the IFlowMonitor with this flow's materialized value.

    Declaration
    public static Source<TOut, TMat2> Monitor<TOut, TMat, TMat2>(this Source<TOut, TMat> flow, Func<TMat, IFlowMonitor, TMat2> combine)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<TMat, IFlowMonitor, TMat2> combine

    TBD

    Returns
    Type Description
    Source<TOut, TMat2>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    TMat2

    TBD

    | Edit this page View Source

    OrElseMaterialized<T, TMat, TMat2, TMat3>(Source<T, TMat>, IGraph<SourceShape<T>, TMat2>, Func<TMat, TMat2, TMat3>)

    Provides a secondary source that will be consumed if this source completes without any elements passing by. As soon as the first element comes through this stream, the alternative will be cancelled.

    It is recommended to use the internally optimized Left<TLeft, TRight>(TLeft, TRight) and Right<TLeft, TRight>(TLeft, TRight) combiners where appropriate instead of manually writing functions that pass through one of the values.

    OrElse<T, TMat>(Source<T, TMat>, IGraph<SourceShape<T>, TMat>)

    Declaration
    public static Source<T, TMat3> OrElseMaterialized<T, TMat, TMat2, TMat3>(this Source<T, TMat> flow, IGraph<SourceShape<T>, TMat2> secondary, Func<TMat, TMat2, TMat3> materializedFunction)
    Parameters
    Type Name Description
    Source<T, TMat> flow

    TBD

    IGraph<SourceShape<T>, TMat2> secondary

    TBD

    Func<TMat, TMat2, TMat3> materializedFunction

    TBD

    Returns
    Type Description
    Source<T, TMat3>

    TBD

    Type Parameters
    Name Description
    T

    TBD

    TMat

    TBD

    TMat2

    TBD

    TMat3

    TBD

    | Edit this page View Source

    OrElse<T, TMat>(Source<T, TMat>, IGraph<SourceShape<T>, TMat>)

    Provides a secondary source that will be consumed if this stream completes without any elements passing by. As soon as the first element comes through this stream, the alternative will be cancelled.

    Note that this Flow will be materialized together with the Source<TOut, TMat> and just kept from producing elements by asserting back-pressure until its time comes or it gets cancelled.

    On errors the stage is failed regardless of source of the error.

    '''Emits when''' element is available from first stream or first stream closed without emitting any elements and an element is available from the second stream

    '''Backpressures when''' downstream backpressures

    '''Completes when''' the primary stream completes after emitting at least one element, when the primary stream completes without emitting and the secondary stream already has completed or when the secondary stream completes

    '''Cancels when''' downstream cancels and additionally the alternative is cancelled as soon as an element passes by from this stream.

    Declaration
    public static Source<T, TMat> OrElse<T, TMat>(this Source<T, TMat> flow, IGraph<SourceShape<T>, TMat> secondary)
    Parameters
    Type Name Description
    Source<T, TMat> flow

    TBD

    IGraph<SourceShape<T>, TMat> secondary

    TBD

    Returns
    Type Description
    Source<T, TMat>

    TBD

    Type Parameters
    Name Description
    T

    TBD

    TMat

    TBD

    | Edit this page View Source

    PrefixAndTail<TOut, TMat>(Source<TOut, TMat>, int)

    Takes up to n elements from the stream and returns a pair containing a strict sequence of the taken element and a stream representing the remaining elements. If n is zero or negative, then this will return a pair of an empty collection and a stream containing the whole upstream unchanged.

    Emits when the configured number of prefix elements are available. Emits this prefix, and the rest as a substream

    Backpressures when downstream backpressures or substream backpressures

    Completes when prefix elements has been consumed and substream has been consumed

    Cancels when downstream cancels or substream cancels
    Declaration
    public static Source<(IImmutableList<TOut>, Source<TOut, NotUsed>), TMat> PrefixAndTail<TOut, TMat>(this Source<TOut, TMat> flow, int n)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    int n

    TBD

    Returns
    Type Description
    Source<(IImmutableList<TOut>, Source<TOut, NotUsed>), TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Prepend<TOut1, TOut2, TMat>(Source<TOut1, TMat>, IGraph<SourceShape<TOut2>, TMat>)

    Prepend the given Source<TOut, TMat> to this IFlow<TOut, TMat>, meaning that before elements are generated from this IFlow<TOut, TMat>, the Source's elements will be produced until it is exhausted, at which point Flow elements will start being produced.

    Note that this IFlow<TOut, TMat> will be materialized together with the Source<TOut, TMat> and just kept from producing elements by asserting back-pressure until its time comes.

    If the given Source<TOut, TMat> gets upstream error - no elements from this IFlow<TOut, TMat> will be pulled.

    Emits when element is available from the given Source<TOut, TMat> or from current stream when the Source<TOut, TMat> is completed

    Backpressures when downstream backpressures

    Completes when this IFlow<TOut, TMat> completes

    Cancels when downstream cancels

    Declaration
    public static Source<TOut2, TMat> Prepend<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, IGraph<SourceShape<TOut2>, TMat> that) where TOut1 : TOut2
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    IGraph<SourceShape<TOut2>, TMat> that

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    RecoverWithRetries<TOut, TMat>(Source<TOut, TMat>, Func<Exception, IGraph<SourceShape<TOut>, TMat>>, int)

    RecoverWithRetries allows to switch to alternative Source on flow failure. It will stay in effect after a failure has been recovered up to attempts number of times so that each time there is a failure it is fed into the partialFunc and a new Source may be materialized. Note that if you pass in 0, this won't attempt to recover at all. Passing in -1 will behave exactly the same as RecoverWithRetries<TOut, TMat>(Source<TOut, TMat>, Func<Exception, IGraph<SourceShape<TOut>, TMat>>, int).

    Since the underlying failure signal onError arrives out-of-band, it might jump over existing elements. This stage can recover the failure signal, but not the skipped elements, which will be dropped.

    Throwing an exception inside RecoverWithRetries will be logged on ERROR level automatically.

    Emits when element is available from the upstream or upstream is failed and element is available from alternative Source

    Backpressures when downstream backpressures

    Completes when upstream completes or upstream failed with exception partialFunc can handle

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> RecoverWithRetries<TOut, TMat>(this Source<TOut, TMat> flow, Func<Exception, IGraph<SourceShape<TOut>, TMat>> partialFunc, int attempts)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<Exception, IGraph<SourceShape<TOut>, TMat>> partialFunc

    Receives the failure cause and returns the new Source to be materialized if any

    int attempts

    Maximum number of retries or -1 to retry indefinitely

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    Exceptions
    Type Condition
    ArgumentException

    if attempts is a negative number other than -1

    | Edit this page View Source

    RecoverWith<TOut, TMat>(Source<TOut, TMat>, Func<Exception, IGraph<SourceShape<TOut>, TMat>>)

    RecoverWith allows to switch to alternative Source on flow failure. It will stay in effect after a failure has been recovered so that each time there is a failure it is fed into the partialFunc and a new Source may be materialized.

    Since the underlying failure signal onError arrives out-of-band, it might jump over existing elements. This stage can recover the failure signal, but not the skipped elements, which will be dropped.

    Throwing an exception inside RecoverWith will be logged on ERROR level automatically.

    Emits when element is available from the upstream or upstream is failed and element is available from alternative Source

    Backpressures when downstream backpressures

    Completes when upstream completes or upstream failed with exception partialFunc can handle

    Cancels when downstream cancels
    Declaration
    [Obsolete("Use RecoverWithRetries instead. [1.1.2]")]
    public static Source<TOut, TMat> RecoverWith<TOut, TMat>(this Source<TOut, TMat> flow, Func<Exception, IGraph<SourceShape<TOut>, TMat>> partialFunc)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<Exception, IGraph<SourceShape<TOut>, TMat>> partialFunc

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Recover<TOut, TMat>(Source<TOut, TMat>, Func<Exception, Option<TOut>>)

    Recover allows to send last element on failure and gracefully complete the stream Since the underlying failure signal onError arrives out-of-band, it might jump over existing elements. This stage can recover the failure signal, but not the skipped elements, which will be dropped.

    Throwing an exception inside Recover will be logged on ERROR level automatically.

    Emits when element is available from the upstream or upstream is failed and partialFunc returns an element

    Backpressures when downstream backpressures

    Completes when upstream completes or upstream failed with exception pf can handle

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Recover<TOut, TMat>(this Source<TOut, TMat> flow, Func<Exception, Option<TOut>> partialFunc)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<Exception, Option<TOut>> partialFunc

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    RepeatPrevious<T, TMat>(Source<T, TMat>)

    Repeats the previous element from upstream until it's replaced by a new value.

    Declaration
    public static Source<T, TMat> RepeatPrevious<T, TMat>(this Source<T, TMat> source)
    Parameters
    Type Name Description
    Source<T, TMat> source

    The previous Source<TOut, TMat> stage in this stream.

    Returns
    Type Description
    Source<T, TMat>
    Type Parameters
    Name Description
    T

    The source's output type.

    TMat

    The materialization type.

    Remarks

    This is designed to allow fan-in stages where output from one of the sources is intermittent / infrequent and users just want the previous value to be reused.

    | Edit this page View Source

    RepeatPrevious<T, TMat>(Source<T, TMat>, Action<T, T>)

    Repeats the previous element from upstream until it's replaced by a new value.

    Declaration
    public static Source<T, TMat> RepeatPrevious<T, TMat>(this Source<T, TMat> source, Action<T, T> onItemUpdated)
    Parameters
    Type Name Description
    Source<T, TMat> source

    The previous Source<TOut, TMat> stage in this stream.

    Action<T, T> onItemUpdated

    A Action<T1, T2> function that allows the stage to perform clean-up operations when the previously repeated value is being changed.

    This is used for things like calling <xref href="System.IDisposable.Dispose" data-throw-if-not-resolved="false"></xref> on the previous value.
    
    Returns
    Type Description
    Source<T, TMat>
    Type Parameters
    Name Description
    T

    The source's output type.

    TMat

    The materialization type.

    Remarks

    This is designed to allow fan-in stages where output from one of the sources is intermittent / infrequent and users just want the previous value to be reused.

    | Edit this page View Source

    ScanAsync<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, Task<TOut2>>)

    Similar to Scan<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, TOut2>) but with a asynchronous function, emits its current value which starts at zero and then applies the current and next value to the given function scan emitting a Task<TResult> that resolves to the next current value.

    If the function scan throws an exception and the supervision decision is Restart current value starts at zero again the stream will continue.

    If the function scan throws an exception and the supervision decision is Resume current value starts at the previous current value, or zero when it doesn't have one, and the stream will continue.

    Emits the Task<TResult> returned by scan completes

    Backpressures when downstream backpressures

    Completes upstream completes and the last task returned by scan completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut2, TMat> ScanAsync<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, TOut2 zero, Func<TOut2, TOut1, Task<TOut2>> scan)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    TOut2 zero

    TBD

    Func<TOut2, TOut1, Task<TOut2>> scan

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    Scan<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, TOut2>)

    Similar to Aggregate<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, TOut2>) but is not a terminal operation, emits its current value which starts at zero and then applies the current and next value to the given function scan, emitting the next current value.

    If the function scan throws an exception and the supervision decision is Restart current value starts at zero again the stream will continue.

    Emits when the function scanning the element returns a new element

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut2, TMat> Scan<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, TOut2 zero, Func<TOut2, TOut1, TOut2> scan)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    TOut2 zero

    TBD

    Func<TOut2, TOut1, TOut2> scan

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    SelectAsyncUnordered<TIn, TOut, TMat>(Source<TIn, TMat>, int, Func<TIn, Task<TOut>>)

    Transform this stream by applying the given function asyncMapper to each of the elements as they pass through this processing step. The function returns a Task and the value of that task will be emitted downstream. The number of tasks that shall run in parallel is given as the first argument to SelectAsyncUnordered<TIn, TOut, TMat>(Source<TIn, TMat>, int, Func<TIn, Task<TOut>>). Each processed element will be emitted dowstream as soon as it is ready, i.e. it is possible that the elements are not emitted downstream in the same order as received from upstream.

    If the group by function asyncMapper throws an exception or if the Task is completed with failure and the supervision decision is Stop the stream will be completed with failure.

    If the group by function asyncMapper throws an exception or if theTask is completed with failure and the supervision decision is Resume or Restart the element is dropped and the stream continues.

    Emits when any of the tasks returned by the provided function complete

    Backpressures when the number of tasks reaches the configured parallelism and the downstream backpressures

    Completes when upstream completes and all tasks has been completed and all elements has been emitted

    Cancels when downstream cancels

    Declaration
    public static Source<TOut, TMat> SelectAsyncUnordered<TIn, TOut, TMat>(this Source<TIn, TMat> flow, int parallelism, Func<TIn, Task<TOut>> asyncMapper)
    Parameters
    Type Name Description
    Source<TIn, TMat> flow
    int parallelism
    Func<TIn, Task<TOut>> asyncMapper
    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TIn
    TOut
    TMat
    See Also
    SelectAsync<TIn, TOut, TMat>(Source<TIn, TMat>, int, Func<TIn, Task<TOut>>)
    | Edit this page View Source

    SelectAsync<TIn, TOut, TMat>(Source<TIn, TMat>, int, Func<TIn, Task<TOut>>)

    Transform this stream by applying the given function asyncMapper to each of the elements as they pass through this processing step. The function returns a Task<TResult> and the value of that task will be emitted downstream. The number of tasks that shall run in parallel is given as the first argument to SelectAsync<TIn, TOut, TMat>(Source<TIn, TMat>, int, Func<TIn, Task<TOut>>). These tasks may complete in any order, but the elements that are emitted downstream are in the same order as received from upstream.

    If the group by function asyncMapper throws an exception or if the Task is completed with failure and the supervision decision is Stop the stream will be completed with failure.

    If the group by function asyncMapper throws an exception or if the Task is completed with failure and the supervision decision is Resume or Restart the element is dropped and the stream continues.

    Emits when the task returned by the provided function finishes for the next element in sequence

    Backpressures when the number of tasks reaches the configured parallelism and the downstream backpressures or the first task is not completed

    Completes when upstream completes and all tasks has been completed and all elements has been emitted

    Cancels when downstream cancels

    Declaration
    public static Source<TOut, TMat> SelectAsync<TIn, TOut, TMat>(this Source<TIn, TMat> flow, int parallelism, Func<TIn, Task<TOut>> asyncMapper)
    Parameters
    Type Name Description
    Source<TIn, TMat> flow
    int parallelism
    Func<TIn, Task<TOut>> asyncMapper
    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TIn
    TOut
    TMat
    See Also
    SelectAsyncUnordered<TIn, TOut, TMat>(Source<TIn, TMat>, int, Func<TIn, Task<TOut>>)
    | Edit this page View Source

    SelectError<TOut, TMat>(Source<TOut, TMat>, Func<Exception, Exception>)

    While similar to Recover<TOut, TMat>(Source<TOut, TMat>, Func<Exception, Option<TOut>>) this stage can be used to transform an error signal to a different one without logging it as an error in the process. So in that sense it is NOT exactly equivalent to Recover(e => throw e2) since Recover would log the e2 error.

    Since the underlying failure signal onError arrives out-of-band, it might jump over existing elements. This stage can recover the failure signal, but not the skipped elements, which will be dropped.

    Similarily to Recover<TOut, TMat>(Source<TOut, TMat>, Func<Exception, Option<TOut>>) throwing an exception inside SelectError will be logged.

    Emits when element is available from the upstream or upstream is failed and selector returns an element

    Backpressures when downstream backpressures

    Completes when upstream completes or upstream failed with exception returned by the selector

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> SelectError<TOut, TMat>(this Source<TOut, TMat> flow, Func<Exception, Exception> selector)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    The upstream stage

    Func<Exception, Exception> selector

    Receives the failure cause and returns the new cause, return the original exception if no other should be applied

    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TOut
    TMat
    | Edit this page View Source

    SelectMany<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<TOut1, IEnumerable<TOut2>>)

    Transform each input element into a sequence of output elements that is then flattened into the output stream.

    The returned sequence MUST NOT contain null values, as they are illegal as stream elements - according to the Reactive Streams specification.

    Emits when the mapping function mapConcater returns an element or there are still remaining elements from the previously calculated collection

    Backpressures when downstream backpressures or there are still remaining elements from the previously calculated collection

    Completes when upstream completes and all remaining elements has been emitted

    Cancels when downstream cancels

    Declaration
    public static Source<TOut2, TMat> SelectMany<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, Func<TOut1, IEnumerable<TOut2>> mapConcater)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow
    Func<TOut1, IEnumerable<TOut2>> mapConcater
    Returns
    Type Description
    Source<TOut2, TMat>
    Type Parameters
    Name Description
    TOut1
    TOut2
    TMat
    | Edit this page View Source

    Select<TIn, TOut, TMat>(Source<TIn, TMat>, Func<TIn, TOut>)

    Transform this stream by applying the given mapper function to each of the elements as they pass through this processing step.

    Emits when the mapping function mapper returns an element

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels

    Declaration
    public static Source<TOut, TMat> Select<TIn, TOut, TMat>(this Source<TIn, TMat> flow, Func<TIn, TOut> mapper)
    Parameters
    Type Name Description
    Source<TIn, TMat> flow
    Func<TIn, TOut> mapper
    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TIn
    TOut
    TMat
    | Edit this page View Source

    SkipWhile<TOut, TMat>(Source<TOut, TMat>, Predicate<TOut>)

    Discard elements at the beginning of the stream while predicate is true. All elements will be taken after predicate returns false first time.

    Emits when predicate returned false and for all following stream elements

    Backpressures when predicate returned false and downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> SkipWhile<TOut, TMat>(this Source<TOut, TMat> flow, Predicate<TOut> predicate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow
    Predicate<TOut> predicate
    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TOut
    TMat
    | Edit this page View Source

    SkipWithin<TOut, TMat>(Source<TOut, TMat>, TimeSpan)

    Discard the elements received within the given duration at beginning of the stream.

    Emits when the specified time elapsed and a new upstream element arrives

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> SkipWithin<TOut, TMat>(this Source<TOut, TMat> flow, TimeSpan duration)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan duration

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Skip<TOut, TMat>(Source<TOut, TMat>, long)

    Discard the given number of elements at the beginning of the stream. No elements will be dropped if n is zero or negative.

    Emits when the specified number of elements has been dropped already

    Backpressures when the specified number of elements has been dropped and downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Skip<TOut, TMat>(this Source<TOut, TMat> flow, long n)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    long n

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Sliding<TOut, TMat>(Source<TOut, TMat>, int, int)

    Apply a sliding window over the stream and return the windows as groups of elements, with the last group possibly smaller than requested due to end-of-stream.

    n must be positive, otherwise IllegalArgumentException is thrown. step must be positive, otherwise IllegalArgumentException is thrown.

    Emits when enough elements have been collected within the window or upstream completed

    Backpressures when a window has been assembled and downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<IEnumerable<TOut>, TMat> Sliding<TOut, TMat>(this Source<TOut, TMat> flow, int n, int step = 1)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    int n

    TBD

    int step

    TBD

    Returns
    Type Description
    Source<IEnumerable<TOut>, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    Exceptions
    Type Condition
    ArgumentException

    Thrown when n or step is less than or equal zero.

    | Edit this page View Source

    SplitAfter<TOut, TMat>(Source<TOut, TMat>, SubstreamCancelStrategy, Func<TOut, bool>)

    This operation applies the given predicate to all incoming elements and emits them to a stream of output streams.It * ends * the current substream when the predicate is true. This means that for the following series of predicate values, three substreams will be produced with lengths 2, 2, and 3:

    {{{ false, true, // elements go into first substream false, true, // elements go into second substream false, false, true // elements go into third substream }}}

    The object returned from this method is not a normal [[Source]] or[[Flow]], it is a SubFlow<TOut, TMat, TClosed>. This means that after this combinator all transformations are applied to all encountered substreams in the same fashion.Substream mode is exited either by closing the substream(i.e.connecting it to a [[Sink]]) or by merging the substreams back together; see the To<TMat2>(IGraph<SinkShape<TOut>, TMat2>) and MergeSubstreams() methods on SubFlow<TOut, TMat, TClosed> for more information.

    It is important to note that the substreams also propagate back-pressure as any other stream, which means that blocking one substream will block the SplitAfter<TOut, TMat>(Source<TOut, TMat>, SubstreamCancelStrategy, Func<TOut, bool>) operator itself—and thereby all substreams—once all internal or explicit buffers are filled.

    If the split predicate throws an exception and the supervision decision is Stop the stream and substreams will be completed with failure.

    If the split predicate throws an exception and the supervision decision is Resume or Restart the element is dropped and the stream and substreams continue.

    Emits when an element passes through.When the provided predicate is true it emits the element and opens a new substream for subsequent element

    Backpressures when there is an element pending for the next substream, but the previous is not fully consumed yet, or the substream backpressures

    Completes when upstream completes

    Cancels when downstream cancels and substreams cancel
    Declaration
    public static SubFlow<TOut, TMat, IRunnableGraph<TMat>> SplitAfter<TOut, TMat>(this Source<TOut, TMat> flow, SubstreamCancelStrategy substreamCancelStrategy, Func<TOut, bool> predicate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    SubstreamCancelStrategy substreamCancelStrategy

    TBD

    Func<TOut, bool> predicate

    TBD

    Returns
    Type Description
    SubFlow<TOut, TMat, IRunnableGraph<TMat>>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    See Also
    SplitWhen<TOut, TMat>(Source<TOut, TMat>, SubstreamCancelStrategy, Func<TOut, bool>)
    | Edit this page View Source

    SplitAfter<TOut, TMat>(Source<TOut, TMat>, Func<TOut, bool>)

    This operation applies the given predicate to all incoming elements and emits them to a stream of output streams. It ends the current substream when the predicate is true.

    Declaration
    public static SubFlow<TOut, TMat, IRunnableGraph<TMat>> SplitAfter<TOut, TMat>(this Source<TOut, TMat> flow, Func<TOut, bool> predicate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<TOut, bool> predicate

    TBD

    Returns
    Type Description
    SubFlow<TOut, TMat, IRunnableGraph<TMat>>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    SplitWhen<TOut, TMat>(Source<TOut, TMat>, SubstreamCancelStrategy, Func<TOut, bool>)

    This operation applies the given predicate to all incoming elements and emits them to a stream of output streams, always beginning a new one with the current element if the given predicate returns true for it. This means that for the following series of predicate values, three substreams will be produced with lengths 1, 2, and 3:

    {{{ false, // element goes into first substream true, false, // elements go into second substream true, false, false // elements go into third substream }}}

    In case the * first * element of the stream matches the predicate, the first substream emitted by splitWhen will start from that element. For example:

    {{{ true, false, false // first substream starts from the split-by element true, false // subsequent substreams operate the same way }}}

    The object returned from this method is not a normal Source<TOut, TMat> or Flow<TIn, TOut, TMat>, it is a SubFlow<TOut, TMat, TClosed>. This means that after this combinator all transformations are applied to all encountered substreams in the same fashion. Substream mode is exited either by closing the substream (i.e. connecting it to a Sink<TIn, TMat>) or by merging the substreams back together; see the To<TMat2>(IGraph<SinkShape<TOut>, TMat2>) and MergeSubstreams() methods on SubFlow<TOut, TMat, TClosed> for more information.

    It is important to note that the substreams also propagate back-pressure as any other stream, which means that blocking one substream will block the SplitWhen<TOut, TMat>(Source<TOut, TMat>, SubstreamCancelStrategy, Func<TOut, bool>) operator itself—and thereby all substreams—once all internal or explicit buffers are filled.

    If the split predicate throws an exception and the supervision decision is Stop the stream and substreams will be completed with failure.

    If the split predicate throws an exception and the supervision decision is Resume or Restart the element is dropped and the stream and substreams continue.

    Emits when an element for which the provided predicate is true, opening and emitting a new substream for subsequent element

    Backpressures when there is an element pending for the next substream, but the previous is not fully consumed yet, or the substream backpressures

    Completes when upstream completes

    Cancels when downstream cancels and substreams cancel
    Declaration
    public static SubFlow<TOut, TMat, IRunnableGraph<TMat>> SplitWhen<TOut, TMat>(this Source<TOut, TMat> flow, SubstreamCancelStrategy substreamCancelStrategy, Func<TOut, bool> predicate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    SubstreamCancelStrategy substreamCancelStrategy

    TBD

    Func<TOut, bool> predicate

    TBD

    Returns
    Type Description
    SubFlow<TOut, TMat, IRunnableGraph<TMat>>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    See Also
    SplitAfter<TOut, TMat>(Source<TOut, TMat>, SubstreamCancelStrategy, Func<TOut, bool>)
    | Edit this page View Source

    SplitWhen<TOut, TMat>(Source<TOut, TMat>, Func<TOut, bool>)

    This operation applies the given predicate to all incoming elements and emits them to a stream of output streams, always beginning a new one with the current element if the given predicate returns true for it.

    Declaration
    public static SubFlow<TOut, TMat, IRunnableGraph<TMat>> SplitWhen<TOut, TMat>(this Source<TOut, TMat> flow, Func<TOut, bool> predicate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<TOut, bool> predicate

    TBD

    Returns
    Type Description
    SubFlow<TOut, TMat, IRunnableGraph<TMat>>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    StatefulSelectMany<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<Func<TOut1, IEnumerable<TOut2>>>)

    Transform each input element into an Enumerable of output elements that is then flattened into the output stream. The transformation is meant to be stateful, which is enabled by creating the transformation function mapConcaterFactory a new for every materialization — the returned function will typically close over mutable objects to store state between invocations. For the stateless variant see SelectMany<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<TOut1, IEnumerable<TOut2>>).

    The returned Enumerable MUST NOT contain null values, as they are illegal as stream elements - according to the Reactive Streams specification.

    Emits when the mapping function returns an element or there are still remaining elements from the previously calculated collection

    Backpressures when downstream backpressures or there are still remaining elements from the previously calculated collection

    Completes when upstream completes and all remaining elements has been emitted

    Cancels when downstream cancels

    See also SelectMany<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<TOut1, IEnumerable<TOut2>>)
    Declaration
    public static Source<TOut2, TMat> StatefulSelectMany<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, Func<Func<TOut1, IEnumerable<TOut2>>> mapConcaterFactory)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow
    Func<Func<TOut1, IEnumerable<TOut2>>> mapConcaterFactory
    Returns
    Type Description
    Source<TOut2, TMat>
    Type Parameters
    Name Description
    TOut1
    TOut2
    TMat
    | Edit this page View Source

    Sum<TOut, TMat>(Source<TOut, TMat>, Func<TOut, TOut, TOut>)

    Similar to Aggregate<TOut1, TOut2, TMat>(Source<TOut1, TMat>, TOut2, Func<TOut2, TOut1, TOut2>) but uses first element as zero element. Applies the given function reduce towards its current and next value, yielding the next current value.

    If the stream is empty (i.e. completes before signaling any elements), the sum stage will fail its downstream with a NoSuchElementException, which is semantically in-line with that standard library collections do in such situations.

    Emits when upstream completes

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Sum<TOut, TMat>(this Source<TOut, TMat> flow, Func<TOut, TOut, TOut> reduce)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<TOut, TOut, TOut> reduce

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    TakeWhile<TOut, TMat>(Source<TOut, TMat>, Predicate<TOut>, bool)

    Terminate processing (and cancel the upstream publisher) after predicate returns false for the first time, including the first failed element iff inclusive is true Due to input buffering some elements may have been requested from upstream publishers that will then not be processed downstream of this step.

    The stream will be completed without producing any elements if predicate is false for the first stream element.

    Emits when the predicate is true

    Backpressures when downstream backpressures

    Completes when predicate returned false (or 1 after predicate returns false if inclusive) or upstream completes

    Cancels when predicate returned false or downstream cancels

    Limit<T, TMat>(Source<T, TMat>, long) LimitWeighted<T, TMat>(Source<T, TMat>, long, Func<T, long>)
    Declaration
    public static Source<TOut, TMat> TakeWhile<TOut, TMat>(this Source<TOut, TMat> flow, Predicate<TOut> predicate, bool inclusive = false)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow
    Predicate<TOut> predicate
    bool inclusive
    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TOut
    TMat
    | Edit this page View Source

    TakeWithin<TOut, TMat>(Source<TOut, TMat>, TimeSpan)

    Terminate processing (and cancel the upstream publisher) after the given duration. Due to input buffering some elements may have been requested from upstream publishers that will then not be processed downstream of this step.

    Note that this can be combined with Take<TOut, TMat>(Source<TOut, TMat>, long) to limit the number of elements within the duration.

    Emits when an upstream element arrives

    Backpressures when downstream backpressures

    Completes when upstream completes or timer fires

    Cancels when downstream cancels or timer fires
    Declaration
    public static Source<TOut, TMat> TakeWithin<TOut, TMat>(this Source<TOut, TMat> flow, TimeSpan duration)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    TimeSpan duration

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Take<TOut, TMat>(Source<TOut, TMat>, long)

    Terminate processing (and cancel the upstream publisher) after the given number of elements. Due to input buffering some elements may have been requested from upstream publishers that will then not be processed downstream of this step.

    The stream will be completed without producing any elements if n is zero or negative.

    Emits when the specified number of elements to take has not yet been reached

    Backpressures when downstream backpressures

    Completes when the defined number of elements has been taken or upstream completes

    Cancels when the defined number of elements has been taken or downstream cancels
    Declaration
    public static Source<TOut, TMat> Take<TOut, TMat>(this Source<TOut, TMat> flow, long n)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    long n

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Throttle<TOut, TMat>(Source<TOut, TMat>, int, TimeSpan, int, ThrottleMode)

    Sends elements downstream with speed limited to elements/per. In other words, this stage set the maximum rate for emitting messages. This combinator works for streams where all elements have the same cost or length.

    Throttle implements the token bucket model. There is a bucket with a given token capacity (burst size or maximumBurst). Tokens drops into the bucket at a given rate and can be "spared" for later use up to bucket capacity to allow some burstiness. Whenever stream wants to send an element, it takes as many tokens from the bucket as number of elements. If there isn't any, throttle waits until the bucket accumulates enough tokens.

    Parameter mode manages behaviour when upstream is faster than throttle rate:

    - Shaping makes pauses before emitting messages to meet throttle rate

    - Enforcing fails with exception when upstream is faster than throttle rate. Enforcing cannot emit elements that cost more than the maximumBurst

    Emits when upstream emits an element and configured time per each element elapsed

    Backpressures when downstream backpressures or the incoming rate is higher than the speed limit

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Throttle<TOut, TMat>(this Source<TOut, TMat> flow, int elements, TimeSpan per, int maximumBurst, ThrottleMode mode)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    int elements

    TBD

    TimeSpan per

    TBD

    int maximumBurst

    TBD

    ThrottleMode mode

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    Exceptions
    Type Condition
    ArgumentException

    Thrown when elements is less than or equal zero, or per timeout is equal Zero or maximumBurst is less than or equal zero in in Enforcing mode.

    | Edit this page View Source

    Throttle<TOut, TMat>(Source<TOut, TMat>, int, TimeSpan, int, Func<TOut, int>, ThrottleMode)

    Sends elements downstream with speed limited to cost/per`. Cost is calculating for each element individually by calling calculateCost function. This combinator works for streams when elements have different cost(length). Streams of ByteString for example.

    Throttle implements the token bucket model. There is a bucket with a given token capacity (burst size or maximumBurst). Tokens drops into the bucket at a given rate and can be spared for later use up to bucket capacity to allow some burstiness. Whenever stream wants to send an element, it takes as many tokens from the bucket as element cost. If there isn't any, throttle waits until the bucket accumulates enough tokens. Elements that costs more than the allowed burst will be delayed proportionally to their cost minus available tokens, meeting the target rate.

    Parameter mode manages behaviour when upstream is faster than throttle rate:

    - Shaping makes pauses before emitting messages to meet throttle rate

    - Enforcing fails with exception when upstream is faster than throttle rate. Enforcing cannot emit elements that cost more than the maximumBurst

    Emits when upstream emits an element and configured time per each element elapsed

    Backpressures when downstream backpressures or the incoming rate is higher than the speed limit

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Throttle<TOut, TMat>(this Source<TOut, TMat> flow, int cost, TimeSpan per, int maximumBurst, Func<TOut, int> calculateCost, ThrottleMode mode)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    int cost

    TBD

    TimeSpan per

    TBD

    int maximumBurst

    TBD

    Func<TOut, int> calculateCost

    TBD

    ThrottleMode mode

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    Transform<TOut1, TOut2, TMat>(Source<TOut1, TMat>, Func<IStage<TOut1, TOut2>>)

    Generic transformation of a stream with a custom processing IStage<TIn, TOut>. This operator makes it possible to extend the Flow API when there is no specialized operator that performs the transformation.

    Declaration
    [Obsolete("Use Via(GraphStage) instead. [1.1.2]")]
    public static Source<TOut2, TMat> Transform<TOut1, TOut2, TMat>(this Source<TOut1, TMat> flow, Func<IStage<TOut1, TOut2>> stageFactory)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow

    TBD

    Func<IStage<TOut1, TOut2>> stageFactory

    TBD

    Returns
    Type Description
    Source<TOut2, TMat>

    TBD

    Type Parameters
    Name Description
    TOut1

    TBD

    TOut2

    TBD

    TMat

    TBD

    | Edit this page View Source

    WatchTermination<TOut, TMat, TMat2>(Source<TOut, TMat>, Func<TMat, Task<Done>, TMat2>)

    Materializes to Task<TResult> that completes on getting termination message. The task completes with success when received complete message from upstream or cancel from downstream. It fails with the same error when received error message from downstream.

    It is recommended to use the internally optimized Left<TLeft, TRight>(TLeft, TRight) and Right<TLeft, TRight>(TLeft, TRight) combiners where appropriate instead of manually writing functions that pass through one of the values.

    Declaration
    public static Source<TOut, TMat2> WatchTermination<TOut, TMat, TMat2>(this Source<TOut, TMat> flow, Func<TMat, Task<Done>, TMat2> materializerFunction)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Func<TMat, Task<Done>, TMat2> materializerFunction

    TBD

    Returns
    Type Description
    Source<TOut, TMat2>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    TMat2

    TBD

    | Edit this page View Source

    Watch<T, TMat>(Source<T, TMat>, IActorRef)

    The operator fails with an WatchedActorTerminatedException if the target actor is terminated.

    '''Emits when''' upstream emits '''Backpressures when''' downstream backpressures '''Completes when''' upstream completes '''Fails when''' the watched actor terminates '''Cancels when''' downstream cancels

    Declaration
    public static Source<T, TMat> Watch<T, TMat>(this Source<T, TMat> flow, IActorRef actorRef)
    Parameters
    Type Name Description
    Source<T, TMat> flow
    IActorRef actorRef
    Returns
    Type Description
    Source<T, TMat>
    Type Parameters
    Name Description
    T
    TMat
    | Edit this page View Source

    WhereNot<TOut, TMat>(Source<TOut, TMat>, Predicate<TOut>)

    Only pass on those elements that NOT satisfy the given predicate.

    Emits when the given predicate returns true for the element

    Backpressures when the given predicate returns true for the element and downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> WhereNot<TOut, TMat>(this Source<TOut, TMat> flow, Predicate<TOut> predicate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow
    Predicate<TOut> predicate
    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TOut
    TMat
    | Edit this page View Source

    Where<TOut, TMat>(Source<TOut, TMat>, Predicate<TOut>)

    Only pass on those elements that satisfy the given predicate.

    Emits when the given predicate returns true for the element

    Backpressures when the given predicate returns true for the element and downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<TOut, TMat> Where<TOut, TMat>(this Source<TOut, TMat> flow, Predicate<TOut> predicate)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow
    Predicate<TOut> predicate
    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TOut
    TMat
    | Edit this page View Source

    WireTapMaterialized<TOut, TMat, TMat2, TMat3>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat2>, Func<TMat, TMat2, TMat3>)

    Attaches the given Sink<TIn, TMat> to this IFlow<TOut, TMat>, as a wire tap, meaning that elements that pass through will also be sent to the wire-tap Sink, without the latter affecting the mainline flow. If the wire-tap Sink backpressures, elements that would've been sent to it will be dropped instead..

    It is similar to AlsoToMaterialized<TOut, TMat, TMat2, TMat3>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat2>, Func<TMat, TMat2, TMat3>) which does backpressure instead of dropping elements.

    It is recommended to use the internally optimized Left<TLeft, TRight>(TLeft, TRight) and Right<TLeft, TRight>(TLeft, TRight) combiners where appropriate instead of manually writing functions that pass through one of the values.
    Declaration
    public static Source<TOut, TMat3> WireTapMaterialized<TOut, TMat, TMat2, TMat3>(this Source<TOut, TMat> flow, IGraph<SinkShape<TOut>, TMat2> that, Func<TMat, TMat2, TMat3> materializerFunction)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow
    IGraph<SinkShape<TOut>, TMat2> that
    Func<TMat, TMat2, TMat3> materializerFunction
    Returns
    Type Description
    Source<TOut, TMat3>
    Type Parameters
    Name Description
    TOut
    TMat
    TMat2
    TMat3
    | Edit this page View Source

    WireTap<TOut, TMat>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat>)

    Attaches the given Sink<TIn, TMat> to this IFlow<TOut, TMat> as a wire tap, meaning that elements that pass through will also be sent to the wire-tap Sink, without the latter affecting the mainline flow. If the wire-tap Sink backpressures, elements that would've been sent to it will be dropped instead.

    It is similar to AlsoTo<TOut, TMat>(Source<TOut, TMat>, IGraph<SinkShape<TOut>, TMat>) which does backpressure instead of dropping elements.

    Emits when element is available and demand exists from the downstream; the element will also be sent to the wire-tap Sink if there is demand.

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels

    Declaration
    public static Source<TOut, TMat> WireTap<TOut, TMat>(this Source<TOut, TMat> flow, IGraph<SinkShape<TOut>, TMat> that)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow
    IGraph<SinkShape<TOut>, TMat> that
    Returns
    Type Description
    Source<TOut, TMat>
    Type Parameters
    Name Description
    TOut
    TMat
    | Edit this page View Source

    WireTap<TOut, TMat>(Source<TOut, TMat>, Action<TOut>)

    This is a simplified version of Akka.Streams.Dsl.WireTap<T> that takes only a simple procedure. Elements will be passed into this "side channel" delegate, and any of its results will be ignored.

    If the wire-tap operation is slow (it backpressures), elements that would've been sent to it will be dropped instead.

    This operation is useful for inspecting the passed through element, usually by means of side-effecting operations (such as `Log`, or emitting metrics), for each element without having to modify it.

    For logging signals (elements, completion, error) consider using the Log<TOut, TMat>(Source<TOut, TMat>, string, Func<TOut, object>, ILoggingAdapter, LogLevel) stage instead, along with appropriate Attributes.LogLevels.

    Emits when upstream emits an element

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels; Note that failures of the action delegate will not cause cancellation

    Declaration
    public static Source<TOut, TMat> WireTap<TOut, TMat>(this Source<TOut, TMat> flow, Action<TOut> action)
    Parameters
    Type Name Description
    Source<TOut, TMat> flow

    TBD

    Action<TOut> action

    TBD

    Returns
    Type Description
    Source<TOut, TMat>

    TBD

    Type Parameters
    Name Description
    TOut

    TBD

    TMat

    TBD

    | Edit this page View Source

    ZipWithIndex<TOut1, TMat>(Source<TOut1, TMat>)

    Combine the elements of current flow into a stream of tuples consisting of all elements paired with their index. Indices start at 0.

    Emits when upstream emits an element and is paired with their index

    Backpressures when downstream backpressures

    Completes when upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<(TOut1, long), TMat> ZipWithIndex<TOut1, TMat>(this Source<TOut1, TMat> flow)
    Parameters
    Type Name Description
    Source<TOut1, TMat> flow
    Returns
    Type Description
    Source<(TOut1, long), TMat>
    Type Parameters
    Name Description
    TOut1
    TMat
    | Edit this page View Source

    ZipWith<T1, T2, T3, TMat>(Source<T1, TMat>, IGraph<SourceShape<T2>, TMat>, Func<T1, T2, T3>)

    Put together the elements of current flow and the given Source<TOut, TMat> into a stream of combined elements using a combiner function.

    Emits when all of the inputs has an element available

    Backpressures when downstream backpressures

    Completes when any upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<T3, TMat> ZipWith<T1, T2, T3, TMat>(this Source<T1, TMat> flow, IGraph<SourceShape<T2>, TMat> other, Func<T1, T2, T3> combine)
    Parameters
    Type Name Description
    Source<T1, TMat> flow

    TBD

    IGraph<SourceShape<T2>, TMat> other

    TBD

    Func<T1, T2, T3> combine

    TBD

    Returns
    Type Description
    Source<T3, TMat>

    TBD

    Type Parameters
    Name Description
    T1

    TBD

    T2

    TBD

    T3

    TBD

    TMat

    TBD

    | Edit this page View Source

    Zip<T1, T2, TMat>(Source<T1, TMat>, IGraph<SourceShape<T2>, TMat>)

    Combine the elements of current flow and the given Source<TOut, TMat> into a stream of tuples.

    Emits when all of the inputs has an element available

    Backpressures when downstream backpressures

    Completes when any upstream completes

    Cancels when downstream cancels
    Declaration
    public static Source<(T1, T2), TMat> Zip<T1, T2, TMat>(this Source<T1, TMat> flow, IGraph<SourceShape<T2>, TMat> other)
    Parameters
    Type Name Description
    Source<T1, TMat> flow

    TBD

    IGraph<SourceShape<T2>, TMat> other

    TBD

    Returns
    Type Description
    Source<(T1, T2), TMat>

    TBD

    Type Parameters
    Name Description
    T1

    TBD

    T2

    TBD

    TMat

    TBD

    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET