Source Methods |
The Source type exposes the following members.
Name | Description | |
---|---|---|
ActorPublisherT |
Creates a SourceTOut, TMat that is materialized to an IActorRef which points to an Actor
created according to the passed in Props. Actor created by the Props must
be ActorPublisherT.
| |
ActorRefT |
Creates a SourceTOut, TMat that is materialized as an IActorRef.
Messages sent to this actor will be emitted to the stream if there is demand from downstream,
otherwise they will be buffered until request for demand is received.
Depending on the defined OverflowStrategy it might drop elements if
there is no space available in the buffer.
The strategy Backpressure is not supported, and an
IllegalArgument("Backpressure overflowStrategy not supported") will be thrown if it is passed as argument.
The buffer can be disabled by using bufferSize of 0 and then received messages are dropped
if there is no demand from downstream. When bufferSize is 0 the overflowStrategy does
not matter. An async boundary is added after this Source; as such, it is never safe to assume the downstream will always generate demand.
The stream can be completed successfully by sending the actor reference a StatusSuccess
message (whose content will be ignored) in which case already buffered elements will be signaled before signaling completion,
or by sending PoisonPill in which case completion will be signaled immediately.
The stream can be completed with failure by sending a StatusFailure to the
actor reference. In case the Actor is still draining its internal buffer (after having received
a StatusSuccess) before signaling completion and it receives a StatusFailure,
the failure will be signaled downstream immediately (instead of the completion signal).
The actor will be stopped when the stream is completed, failed or canceled from downstream,
i.e. you can watch it to get notified when that happens.
| |
AsSubscriberT |
Creates a SourceTOut, TMat that is materialized as a ISubscriber | |
CombineT, TOut2 |
Combines several sources with fun-in strategy like MergeTIn, TOut or ConcatTIn, TOut and returns SourceTOut, TMat.
| |
CycleT |
Create SourceTOut, TMat that will continually produce given elements in specified order.
Start a new cycled SourceTOut, TMat from the given elements. The producer stream of elements
will continue infinitely by repeating the sequence of elements provided by function parameter.
| |
EmptyT |
A SourceTOut, TMat with no elements, i.e. an empty stream that is completed immediately for every connected SinkTIn, TMat.
| |
FailedT |
Create a SourceTOut, TMat that immediately ends the stream with the cause error to every connected SinkTIn, TMat.
| |
FromT |
Helper to create SourceTOut, TMat from IEnumerableT.
Example usage: Source.From(Enumerable.Range(1, 10))
Starts a new SourceTOut, TMat from the given IEnumerableT. This is like starting from an
Enumerator, but every Subscriber directly attached to the Publisher of this
stream will see an individual flow of elements (always starting from the
beginning) regardless of when they subscribed.
| |
FromEnumeratorT |
Helper to create SourceTOut, TMat from IEnumeratorT.
Example usage: Source.FromEnumerator(() => Enumerable.Range(1, 10))
Start a new SourceTOut, TMat from the given function that produces an IEnumerableT.
The produced stream of elements will continue until the enumerator runs empty
or fails during evaluation of the [!:IEnumerator<T>.MoveNext] method.
Elements are pulled out of the enumerator in accordance with the demand coming
from the downstream transformation steps.
| |
FromGraphT, TMat |
A graph with the shape of a source logically is a source, this method makes
it so also in type.
| |
FromPublisherT |
Helper to create SourceTOut, TMat from IPublisher.
Construct a transformation starting with given publisher. The transformation steps
are executed by a series of IProcessor instances
that mediate the flow of elements downstream and the propagation of
back-pressure upstream.
| |
FromTaskT |
Start a new SourceTOut, TMat from the given TaskTResult. The stream will consist of
one element when the TaskTResult is completed with a successful value, which
may happen before or after materializing the IFlowTOut, TMat.
The stream terminates with a failure if the task is completed with a failure.
| |
MaybeT |
Create a SourceTOut, TMat which materializes a TaskCompletionSourceTResult which controls what element
will be emitted by the Source.
If the materialized promise is completed with a Some, that value will be produced downstream,
followed by completion.
If the materialized promise is completed with a None, no value will be produced downstream and completion will
be signaled immediately.
If the materialized promise is completed with a failure, then the returned source will terminate with that error.
If the downstream of this source cancels before the promise has been completed, then the promise will be completed
with None.
| |
QueueT |
Creates a SourceTOut, TMat that is materialized as an ISourceQueueWithCompleteT.
You can push elements to the queue and they will be emitted to the stream if there is demand from downstream,
otherwise they will be buffered until request for demand is received.
Depending on the defined OverflowStrategy it might drop elements if
there is no space available in the buffer.
Acknowledgement mechanism is available.
[!:ISourceQueueWithComplete<T>.OfferAsync] returns Task which completes with true
if element was added to buffer or sent downstream. It completes
with false if element was dropped.
The strategy Backpressure will not complete [!:ISourceQueueWithComplete<T>.OfferAsync] until buffer is full.
The buffer can be disabled by using bufferSize of 0 and then received messages are dropped
if there is no demand from downstream. When bufferSize is 0 the overflowStrategy does
not matter.
| |
RepeatT |
Create a SourceTOut, TMat that will continually emit the given element.
| |
ShapeT |
TBD
| |
SingleT |
Create a SourceTOut, TMat with one element.
Every connected SinkTIn, TMat of this stream will see an individual stream consisting of one element.
| |
TickT |
Elements are emitted periodically with the specified interval.
The tick element will be delivered to downstream consumers that has requested any elements.
If a consumer has not requested any elements at the point in time when the tick
element is produced it will not receive that tick element later. It will
receive new tick elements as soon as it has requested more elements.
| |
UnfoldTState, TElem |
Create a SourceTOut, TMat that will unfold a value of type TState into
a pair of the next state TState and output elements of type TElem.
| |
UnfoldAsyncTState, TElem |
Same as UnfoldTState, TElem(TState, FuncTState, TupleTState, TElem), but uses an async function to generate the next state-element tuple.
| |
UnfoldInfiniteTState, TElem |
Simpler UnfoldTState, TElem(TState, FuncTState, TupleTState, TElem), for infinite sequences.
| |
UnfoldResourceT, TSource |
Start a new SourceTOut, TMat from some resource which can be opened, read and closed.
Interaction with resource happens in a blocking way.
Example:
{{{
Source.unfoldResource(
() => new BufferedReader(new FileReader("...")),
reader => Option(reader.readLine()),
reader => reader.close())
}}}
You can use the supervision strategy to handle exceptions for read function. All exceptions thrown by create
or close will fail the stream.
Restart supervision strategy will close and create blocking IO again. Default strategy is Stop which means
that stream will be terminated on error in `read` function by default.
You can configure the default dispatcher for this Source by changing the `akka.stream.blocking-io-dispatcher` or
set it for a given Source by using CreateDispatcher(String).
| |
UnfoldResourceAsyncT, TSource |
Start a new SourceTOut, TMat from some resource which can be opened, read and closed.
It's similar to UnfoldResourceT, TSource(FuncTSource, FuncTSource, OptionT, ActionTSource) but takes functions that return Tasks instead of plain values.
You can use the supervision strategy to handle exceptions for read function or failures of produced Tasks.
All exceptions thrown by create or close as well as fails of returned futures will fail the stream.
Restart supervision strategy will close and create resource .Default strategy is Stop which means
that stream will be terminated on error in read function (or task) by default.
You can configure the default dispatcher for this Source by changing the `akka.stream.blocking-io-dispatcher` or
set it for a given Source by using CreateDispatcher(String).
| |
ZipNT |
Combines the elements of multiple streams into a stream of lists.
| |
ZipWithNT, TOut2 |
Combines the elements of multiple streams into a stream of sequences using a combiner function.
|