Class Sink
TBD
Inherited Members
Namespace: Akka.Streams.Dsl
Assembly: Akka.Streams.dll
Syntax
public static class Sink
Methods
| Edit this page View SourceActorRefWithAck<TIn>(IActorRef, object, object, object, Func<Exception, object>)
Sends the elements of the stream to the given IActorRef that sends back back-pressure signal.
First element is always onInitMessage, then stream is waiting for acknowledgement message
ackMessage from the given actor which means that it is ready to process
elements.It also requires ackMessage message after each stream element
to make backpressure work.
If the target actor terminates the stream will be canceled.
When the stream is completed successfully the given onCompleteMessage
will be sent to the destination actor.
When the stream is completed with failure - result of onFailureMessage
function will be sent to the destination actor.
Declaration
public static Sink<TIn, NotUsed> ActorRefWithAck<TIn>(IActorRef actorRef, object onInitMessage, object ackMessage, object onCompleteMessage, Func<Exception, object> onFailureMessage = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorRef | TBD |
| object | onInitMessage | TBD |
| object | ackMessage | TBD |
| object | onCompleteMessage | TBD |
| Func<Exception, object> | onFailureMessage | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
ActorRef<TIn>(IActorRef, object)
Sends the elements of the stream to the given IActorRef.
If the target actor terminates the stream will be canceled.
When the stream is completed successfully the given onCompleteMessage
will be sent to the destination actor.
When the stream is completed with failure a Status.Failure
message will be sent to the destination actor.
It will request at most MaxInputBufferSize number of elements from upstream, but there is no back-pressure signal from the destination actor, i.e. if the actor is not consuming the messages fast enough the mailbox of the actor will grow. For potentially slow consumer actors it is recommended to use a bounded mailbox with zero PushTimeOut or use a rate limiting stage in front of this Sink<TIn, TMat>.
Declaration
[Obsolete("Use overload accepting both on complete and on failure message")]
public static Sink<TIn, NotUsed> ActorRef<TIn>(IActorRef actorRef, object onCompleteMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorRef | TBD |
| object | onCompleteMessage | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
ActorRef<TIn>(IActorRef, object, Func<Exception, object>)
INTERNAL API
Sends the elements of the stream to the given IActorRef.
If the target actor terminates the stream will be canceled.
When the stream is completed successfully the given onCompleteMessage
will be sent to the destination actor.
When the stream is completed with failure the onFailureMessage will be
invoked and its result will be sent to the destination actor.
It will request at most MaxInputBufferSize number of elements from upstream, but there is no back-pressure signal from the destination actor, i.e. if the actor is not consuming the messages fast enough the mailbox of the actor will grow. For potentially slow consumer actors it is recommended to use a bounded mailbox with zero PushTimeOut or use a rate limiting stage in front of this Sink<TIn, TMat>.
Declaration
public static Sink<TIn, NotUsed> ActorRef<TIn>(IActorRef actorRef, object onCompleteMessage, Func<Exception, object> onFailureMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorRef | TBD |
| object | onCompleteMessage | TBD |
| Func<Exception, object> | onFailureMessage | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, NotUsed> |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
ActorSubscriber<TIn>(Props)
Creates a Sink<TIn, TMat> that is materialized to an IActorRef which points to an Actor
created according to the passed in Props. Actor created by the props should
be Akka.Streams.Implementation.ActorSubscriberSink<TIn>.
Declaration
public static Sink<TIn, IActorRef> ActorSubscriber<TIn>(Props props)
Parameters
| Type | Name | Description |
|---|---|---|
| Props | props | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, IActorRef> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
AggregateAsync<TIn, TOut>(TOut, Func<TOut, TIn, Task<TOut>>)
A Sink<TIn, TMat> that will invoke the given asynchronous function for every received element,
giving it its previous output (or the given zero value) and the element as input.
The returned Task will be completed with value of the final
function evaluation when the input stream ends, or completed with "Failure"
if there is a failure signaled in the stream.
Declaration
public static Sink<TIn, Task<TOut>> AggregateAsync<TIn, TOut>(TOut zero, Func<TOut, TIn, Task<TOut>> aggregate)
Parameters
| Type | Name | Description |
|---|---|---|
| TOut | zero | TBD |
| Func<TOut, TIn, Task<TOut>> | aggregate | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<TOut>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
| TOut | TBD |
Aggregate<TIn, TOut>(TOut, Func<TOut, TIn, TOut>)
A Sink<TIn, TMat> that will invoke the given aggregate function for every received element,
giving it its previous output (or the given zero value) and the element as input.
The returned Task will be completed with value of the final
function evaluation when the input stream ends, or completed with the streams exception
if there is a failure signaled in the stream.
AggregateAsync<TIn, TOut>(TOut, Func<TOut, TIn, Task<TOut>>)
Declaration
public static Sink<TIn, Task<TOut>> Aggregate<TIn, TOut>(TOut zero, Func<TOut, TIn, TOut> aggregate)
Parameters
| Type | Name | Description |
|---|---|---|
| TOut | zero | TBD |
| Func<TOut, TIn, TOut> | aggregate | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<TOut>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
| TOut | TBD |
AsObservable<T>()
A Sink<TIn, TMat> that materializes into a IObservable<T>. It supports multiple subscribers. Since observables have no notion of backpressure, it will push incoming elements as fast as possible, potentially risking process overrun.
Declaration
public static Sink<T, IObservable<T>> AsObservable<T>()
Returns
| Type | Description |
|---|---|
| Sink<T, IObservable<T>> |
Type Parameters
| Name | Description |
|---|---|
| T |
AsPublisher<TIn>(bool)
A Sink<TIn, TMat> that materializes into a Reactive.Streams.IPublisher<T>.
If fanout is true, the materialized Reactive.Streams.IPublisher<T> will support multiple Reactive.Streams.ISubscriber<T>`s and
the size of the MaxInputBufferSize configured for this stage becomes the maximum number of elements that
the fastest Reactive.Streams.ISubscriber<T> can be ahead of the slowest one before slowing
the processing down due to back pressure.
If fanout is false then the materialized Reactive.Streams.IPublisher<T> will only support a single Reactive.Streams.ISubscriber<T> and
reject any additional Reactive.Streams.ISubscriber<T>`s.
Declaration
public static Sink<TIn, IPublisher<TIn>> AsPublisher<TIn>(bool fanout)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | fanout | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, IPublisher<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
Cancelled<TIn>()
A Sink<TIn, TMat> that immediately cancels its upstream after materialization.
Declaration
public static Sink<TIn, NotUsed> Cancelled<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
ChannelReader<T>(int, bool, BoundedChannelFullMode)
Declaration
public static Sink<T, ChannelReader<T>> ChannelReader<T>(int bufferSize, bool singleReader, BoundedChannelFullMode fullMode = BoundedChannelFullMode.Wait)
Parameters
| Type | Name | Description |
|---|---|---|
| int | bufferSize | |
| bool | singleReader | |
| BoundedChannelFullMode | fullMode |
Returns
| Type | Description |
|---|---|
| Sink<T, ChannelReader<T>> |
Type Parameters
| Name | Description |
|---|---|
| T |
Combine<TIn, TOut, TMat>(Func<int, IGraph<UniformFanOutShape<TIn, TOut>, TMat>>, Sink<TOut, NotUsed>, Sink<TOut, NotUsed>, params Sink<TOut, NotUsed>[])
Combine several sinks with fan-out strategy like Broadcast<T> or Balance<T> and returns Sink<TIn, TMat>.
Declaration
public static Sink<TIn, NotUsed> Combine<TIn, TOut, TMat>(Func<int, IGraph<UniformFanOutShape<TIn, TOut>, TMat>> strategy, Sink<TOut, NotUsed> first, Sink<TOut, NotUsed> second, params Sink<TOut, NotUsed>[] rest)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<int, IGraph<UniformFanOutShape<TIn, TOut>, TMat>> | strategy | TBD |
| Sink<TOut, NotUsed> | first | TBD |
| Sink<TOut, NotUsed> | second | TBD |
| Sink<TOut, NotUsed>[] | rest | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
| TOut | TBD |
| TMat | TBD |
Create<TIn>(ISubscriber<TIn>)
Helper to create Sink<TIn, TMat> from Reactive.Streams.ISubscriber<T>.
Declaration
public static Sink<TIn, object> Create<TIn>(ISubscriber<TIn> subscriber)
Parameters
| Type | Name | Description |
|---|---|---|
| ISubscriber<TIn> | subscriber | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, object> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
FanoutPublisher<TIn>()
A Sink<TIn, TMat> that materializes into Reactive.Streams.IPublisher<T> that can handle more than one Reactive.Streams.ISubscriber<T>.
Declaration
public static Sink<TIn, IPublisher<TIn>> FanoutPublisher<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, IPublisher<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
FirstOrDefault<TIn>()
A Sink<TIn, TMat> that materializes into a Task<TResult> of the first value received. If the stream completes before signaling at least a single element, the Task will return default value. If the stream signals an error errors before signaling at least a single element, the Task will be failed with the streams exception.
Declaration
public static Sink<TIn, Task<TIn>> FirstOrDefault<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
First<TIn>()
A Sink<TIn, TMat> that materializes into a Task<TResult> of the first value received. If the stream completes before signaling at least a single element, the Task will be failed with a NoSuchElementException. If the stream signals an error before signaling at least a single element, the Task will be failed with the streams exception.
Declaration
public static Sink<TIn, Task<TIn>> First<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | TBD |
ForEachAsync<TIn>(int, Func<TIn, Task>)
A Sink<TIn, TMat> that will invoke the given async action for each received element.
The sink is materialized into a Task will be completed with success when reaching the
normal end of the stream, or completed with a failure if there is a failure signaled in
the stream.
Declaration
public static Sink<TIn, Task<Done>> ForEachAsync<TIn>(int parallelism, Func<TIn, Task> action)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parallelism | Number of parallel execution allowed |
| Func<TIn, Task> | action | Async function delegate to be executed on all elements |
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<Done>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | Input element type |
ForEachParallel<TIn>(int, Action<TIn>)
A Sink<TIn, TMat> that will invoke the given action
to each of the elements as they pass in. The sink is materialized into a Task.
If the action throws an exception and the supervision decision is Stop the Task will be completed with failure.
If the action throws an exception and the supervision decision is Resume or Restart the element is dropped and the stream continues.
See also Akka.Streams.Implementation.Fusing.SelectAsyncUnordered<TIn, TOut>Declaration
[Obsolete("Use `ForEachAsync` instead, it allows you to choose how to run the procedure, by calling some other API returning a Task or using Task.Run. Obsolete since 1.5.2")]
public static Sink<TIn, Task<Done>> ForEachParallel<TIn>(int parallelism, Action<TIn> action)
Parameters
| Type | Name | Description |
|---|---|---|
| int | parallelism | TBD |
| Action<TIn> | action | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<Done>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
ForEach<TIn>(Action<TIn>)
A Sink<TIn, TMat> that will invoke the given action for each received element.
The sink is materialized into a Task will be completed with success when reaching the
normal end of the stream, or completed with a failure if there is a failure signaled in
the stream.
Declaration
public static Sink<TIn, Task<Done>> ForEach<TIn>(Action<TIn> action)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<TIn> | action | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<Done>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
FromGraph<TIn, TMat>(IGraph<SinkShape<TIn>, TMat>)
A graph with the shape of a sink logically is a sink, this method makes it so also in type.
Declaration
public static Sink<TIn, TMat> FromGraph<TIn, TMat>(IGraph<SinkShape<TIn>, TMat> graph)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<SinkShape<TIn>, TMat> | graph | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, TMat> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
| TMat | TBD |
FromSubscriber<TIn>(ISubscriber<TIn>)
Helper to create Sink<TIn, TMat> from Reactive.Streams.ISubscriber<T>.
Declaration
public static Sink<TIn, NotUsed> FromSubscriber<TIn>(ISubscriber<TIn> subscriber)
Parameters
| Type | Name | Description |
|---|---|---|
| ISubscriber<TIn> | subscriber | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
FromWriter<T>(ChannelWriter<T>, bool)
Declaration
public static Sink<T, NotUsed> FromWriter<T>(ChannelWriter<T> writer, bool isOwner)
Parameters
| Type | Name | Description |
|---|---|---|
| ChannelWriter<T> | writer | |
| bool | isOwner |
Returns
| Type | Description |
|---|---|
| Sink<T, NotUsed> |
Type Parameters
| Name | Description |
|---|---|
| T |
Ignore<TIn>()
A Sink<TIn, TMat> that will consume the stream and discard the elements.
Declaration
public static Sink<TIn, Task<Done>> Ignore<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<Done>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
LastOrDefault<TIn>()
A Sink<TIn, TMat> that materializes into a Task<TResult> of the last value received. If the stream completes before signaling at least a single element, the Task will be return a default value. If the stream signals an error, the Task will be failed with the stream's exception.
Declaration
public static Sink<TIn, Task<TIn>> LastOrDefault<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
Last<TIn>()
A Sink<TIn, TMat> that materializes into a Task<TResult> of the last value received. If the stream completes before signaling at least a single element, the Task will be failed with a NoSuchElementException. If the stream signals an error, the Task will be failed with the stream's exception.
Declaration
public static Sink<TIn, Task<TIn>> Last<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
LazyInitAsync<TIn, TMat>(Func<Task<Sink<TIn, TMat>>>)
Creates a real Sink<TIn, TMat> upon receiving the first element. Internal Sink<TIn, TMat> will not be created if there are no elements, because of completion or error.
If upstream completes before an element was received then the Task is completed with `default`.
If upstream fails before an element was received, sinkFactory throws an exception, or materialization of the internal
sink fails then the Task is completed with the exception.
Otherwise the Task is completed with the materialized value of the internal sink.
Declaration
public static Sink<TIn, Task<Option<TMat>>> LazyInitAsync<TIn, TMat>(Func<Task<Sink<TIn, TMat>>> sinkFactory)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<Task<Sink<TIn, TMat>>> | sinkFactory | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<Option<TMat>>> |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
| TMat | TBD |
LazySink<TIn, TMat>(Func<TIn, Task<Sink<TIn, TMat>>>, Func<TMat>)
Creates a real Sink<TIn, TMat> upon receiving the first element. Internal Sink<TIn, TMat> will not be created if there are no elements, because of completion or error.
If upstream completes before an element was received then the Task is completed with the value created by fallback.
If upstream fails before an element was received, sinkFactory throws an exception, or materialization of the internal
sink fails then the Task is completed with the exception.
Otherwise the Task is completed with the materialized value of the internal sink.
Declaration
[Obsolete("Use LazyInitAsync instead. LazyInitAsync no more needs a fallback function and the materialized value more clearly indicates if the internal sink was materialized or not.")]
public static Sink<TIn, Task<TMat>> LazySink<TIn, TMat>(Func<TIn, Task<Sink<TIn, TMat>>> sinkFactory, Func<TMat> fallback)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TIn, Task<Sink<TIn, TMat>>> | sinkFactory | TBD |
| Func<TMat> | fallback | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<TMat>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
| TMat | TBD |
OnComplete<TIn>(Action, Action<Exception>)
A Sink<TIn, TMat> that when the flow is completed, either through a failure or normal
completion, apply the provided function with success or failure.
Declaration
public static Sink<TIn, NotUsed> OnComplete<TIn>(Action success, Action<Exception> failure)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | success | TBD |
| Action<Exception> | failure | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
Publisher<TIn>()
A Sink<TIn, TMat> that materializes into a Reactive.Streams.IPublisher<T>. that can handle one Reactive.Streams.ISubscriber<T>.
Declaration
public static Sink<TIn, IPublisher<TIn>> Publisher<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, IPublisher<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
Queue<TIn>()
Creates a Sink<TIn, TMat> that is materialized as an ISinkQueue<T>. PullAsync() method is pulling element from the stream and returns Task<TResult>. Task completes when element is available.
Before calling the pull method a second time you need to wait until previous future completes. Pull returns failed future with IllegalStateException if previous future has not yet completed.
Sink<TIn, TMat> will request at most number of elements equal to size of inputBuffer from upstream and then stop back pressure. You can configure size of input by using WithAttributes method.
For stream completion you need to pull all elements from ISinkQueue<T> including last None as completion marker.
Declaration
public static Sink<TIn, ISinkQueue<TIn>> Queue<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, ISinkQueue<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
Seq<TIn>()
A Sink<TIn, TMat> that keeps on collecting incoming elements until upstream terminates.
As upstream may be unbounded, Flow.Create{T}().Take or the stricter Flow.Create{T}().Limit (and their variants)
may be used to ensure boundedness.
Materializes into a Task of Seq<TIn>() containing all the collected elements.
Seq is limited to MaxValue elements, this Sink will cancel the stream
after having received that many elements.
Declaration
public static Sink<TIn, Task<IImmutableList<TIn>>> Seq<TIn>()
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<IImmutableList<TIn>>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
Shape<T>(string)
TBD
Declaration
public static SinkShape<T> Shape<T>(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | TBD |
Returns
| Type | Description |
|---|---|
| SinkShape<T> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
Sum<TIn>(Func<TIn, TIn, TIn>)
A Sink<TIn, TMat> that will invoke the given reduce for every received element, giving it its previous
output (from the second element) and the element as input.
The returned Task<TResult> will be completed with value of the final
function evaluation when the input stream ends, or completed with `Failure`
if there is a failure signaled in the stream.
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.
Adheres to the ActorAttributes.SupervisionStrategy attribute.
Declaration
public static Sink<TIn, Task<TIn>> Sum<TIn>(Func<TIn, TIn, TIn> reduce)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TIn, TIn, TIn> | reduce | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, Task<TIn>> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
Wrap<TIn, TMat>(IGraph<SinkShape<TIn>, TMat>)
A graph with the shape of a sink logically is a sink, this method makes it so also in type.
Declaration
public static Sink<TIn, TMat> Wrap<TIn, TMat>(IGraph<SinkShape<TIn>, TMat> graph)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<SinkShape<TIn>, TMat> | graph | TBD |
Returns
| Type | Description |
|---|---|
| Sink<TIn, TMat> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TIn | TBD |
| TMat | TBD |
Edit this page