Class Source<TOut, TMat>
A Source<TOut, TMat> is a set of stream processing steps that has one open output. It can comprise any number of internal sources and transformations that are wired together, or it can be an "atomic" source, e.g. from a collection or a file. Materialization turns a Source into a Reactive Streams Reactive.Streams.IPublisher<T> (at least conceptually).
Inherited Members
Namespace: Akka.Streams.Dsl
Assembly: Akka.Streams.dll
Syntax
public sealed class Source<TOut, TMat> : IFlow<TOut, TMat>, IGraph<SourceShape<TOut>, TMat>, IGraph<SourceShape<TOut>>
Type Parameters
| Name | Description |
|---|---|
| TOut | TBD |
| TMat | TBD |
Constructors
| Edit this page View SourceSource(IModule)
TBD
Declaration
public Source(IModule module)
Parameters
| Type | Name | Description |
|---|---|---|
| IModule | module | TBD |
Properties
| Edit this page View SourceModule
TBD
Declaration
public IModule Module { get; }
Property Value
| Type | Description |
|---|---|
| IModule |
Shape
TBD
Declaration
public SourceShape<TOut> Shape { get; }
Property Value
| Type | Description |
|---|---|
| SourceShape<TOut> |
Methods
| Edit this page View SourceAddAttributes(Attributes)
Add the given attributes to this Source<TOut, TMat>. Further calls to WithAttributes(Attributes) will not remove these attributes. Note that this operation has no effect on an empty Flow (because the attributes apply only to the contained processing stages).
Declaration
public Source<TOut, TMat> AddAttributes(Attributes attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| Attributes | attributes | TBD |
Returns
| Type | Description |
|---|---|
| Source<TOut, TMat> | TBD |
Ask<TOut2>(IActorRef, TimeSpan, int)
Use the ask pattern to send a request-reply message to the target actorRef.
If any of the asks times out it will fail the stream with a AskTimeoutException.
Parallelism limits the number of how many asks can be "in flight" at the same time. Please note that the elements emitted by this operator are in-order with regards to the asks being issued (i.e. same behaviour as SelectAsync<TIn, TOut, TMat>(Source<TIn, TMat>, int, Func<TIn, Task<TOut>>)).
The operator fails with an WatchedActorTerminatedException if the target actor is terminated, or with an TimeoutException in case the ask exceeds the timeout passed in.
Adheres to the ActorAttributes.SupervisionStrategy attribute.
'''Emits when''' the futures (in submission order) created by the ask pattern internally are completed. '''Backpressures when''' the number of futures reaches the configured parallelism and the downstream backpressures. '''Completes when''' upstream completes and all futures have been completed and all elements have been emitted. '''Fails when''' the passed in actor terminates, or a timeout is exceeded in any of the asks performed. '''Cancels when''' downstream cancels.
Declaration
public Source<TOut2, TMat> Ask<TOut2>(IActorRef actorRef, TimeSpan timeout, int parallelism = 2)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorRef | |
| TimeSpan | timeout | |
| int | parallelism |
Returns
| Type | Description |
|---|---|
| Source<TOut2, TMat> |
Type Parameters
| Name | Description |
|---|---|
| TOut2 |
Async()
Put an asynchronous boundary around this Source.
Declaration
public Source<TOut, TMat> Async()
Returns
| Type | Description |
|---|---|
| Source<TOut, TMat> | TBD |
Combine<T, TOut2>(Source<T, NotUsed>, Source<T, NotUsed>, Func<int, IGraph<UniformFanInShape<T, TOut2>, NotUsed>>, params Source<T, NotUsed>[])
Combines several sources with fun-in strategy like Merge<TIn, TOut> or Concat<TIn, TOut> and returns Source<TOut, TMat>.
Declaration
public Source<TOut2, NotUsed> Combine<T, TOut2>(Source<T, NotUsed> first, Source<T, NotUsed> second, Func<int, IGraph<UniformFanInShape<T, TOut2>, NotUsed>> strategy, params Source<T, NotUsed>[] rest)
Parameters
| Type | Name | Description |
|---|---|---|
| Source<T, NotUsed> | first | TBD |
| Source<T, NotUsed> | second | TBD |
| Func<int, IGraph<UniformFanInShape<T, TOut2>, NotUsed>> | strategy | TBD |
| Source<T, NotUsed>[] | rest | TBD |
Returns
| Type | Description |
|---|---|
| Source<TOut2, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
| TOut2 | TBD |
ConcatMaterialized<TMat2, TMat3>(IGraph<SourceShape<TOut>, TMat2>, Func<TMat, TMat2, TMat3>)
Concatenate the given Source<TOut, TMat> to this Flow<TIn, 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 Flow and just kept from producing elements by asserting back-pressure until its time comes.
If this Flow<TIn, TOut, TMat> gets upstream error - no elements from the given Source<TOut, TMat> will be pulled.
@see Concat<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 Source<TOut, TMat3> ConcatMaterialized<TMat2, TMat3>(IGraph<SourceShape<TOut>, TMat2> that, Func<TMat, TMat2, TMat3> materializedFunction)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<SourceShape<TOut>, TMat2> | that | TBD |
| Func<TMat, TMat2, TMat3> | materializedFunction | TBD |
Returns
| Type | Description |
|---|---|
| Source<TOut, TMat3> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TMat2 | TBD |
| TMat3 | TBD |
MapMaterializedValue<TMat2>(Func<TMat, TMat2>)
Transform only the materialized value of this Source, leaving all other properties as they were.
Declaration
public Source<TOut, TMat2> MapMaterializedValue<TMat2>(Func<TMat, TMat2> mapFunc)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TMat, TMat2> | mapFunc | TBD |
Returns
| Type | Description |
|---|---|
| Source<TOut, TMat2> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TMat2 | TBD |
Named(string)
Add a name attribute to this Source.
Declaration
public Source<TOut, TMat> Named(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | TBD |
Returns
| Type | Description |
|---|---|
| Source<TOut, TMat> | TBD |
PreMaterialize(ActorSystem)
Materializes this Source immediately.
Declaration
public (TMat, Source<TOut, NotUsed>) PreMaterialize(ActorSystem actorSystem)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | actorSystem | The ActorSystem. |
Returns
| Type | Description |
|---|---|
| (TMat, Source<TOut, NotUsed>) | A tuple containing the (1) materialized value and (2) a new Source that can be used to consume elements from the newly materialized Source. |
PreMaterialize(IMaterializer)
Materializes this Source immediately.
Declaration
public (TMat, Source<TOut, NotUsed>) PreMaterialize(IMaterializer materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IMaterializer | materializer | The materializer. |
Returns
| Type | Description |
|---|---|
| (TMat, Source<TOut, NotUsed>) | A tuple containing the (1) materialized value and (2) a new Source that can be used to consume elements from the newly materialized Source. |
RunAggregateAsync<TOut2>(TOut2, Func<TOut2, TOut, Task<TOut2>>, ActorSystem)
Shortcut for running this Source<TOut, TMat> with a async aggregate function.
The given function is invoked for every received element, giving it its previous
output (or the given zero value) 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.
Declaration
public Task<TOut2> RunAggregateAsync<TOut2>(TOut2 zero, Func<TOut2, TOut, Task<TOut2>> aggregate, ActorSystem materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| TOut2 | zero | TBD |
| Func<TOut2, TOut, Task<TOut2>> | aggregate | TBD |
| ActorSystem | materializer | TBD |
Returns
| Type | Description |
|---|---|
| Task<TOut2> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TOut2 | TBD |
RunAggregateAsync<TOut2>(TOut2, Func<TOut2, TOut, Task<TOut2>>, IMaterializer)
Shortcut for running this Source<TOut, TMat> with a async aggregate function.
The given function is invoked for every received element, giving it its previous
output (or the given zero value) 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.
Declaration
public Task<TOut2> RunAggregateAsync<TOut2>(TOut2 zero, Func<TOut2, TOut, Task<TOut2>> aggregate, IMaterializer materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| TOut2 | zero | TBD |
| Func<TOut2, TOut, Task<TOut2>> | aggregate | TBD |
| IMaterializer | materializer | TBD |
Returns
| Type | Description |
|---|---|
| Task<TOut2> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TOut2 | TBD |
RunAggregate<TOut2>(TOut2, Func<TOut2, TOut, TOut2>, ActorSystem)
Shortcut for running this Source<TOut, TMat> with a fold function.
The given function is invoked for every received element, giving it its previous
output (or the given zero value) 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.
Declaration
public Task<TOut2> RunAggregate<TOut2>(TOut2 zero, Func<TOut2, TOut, TOut2> aggregate, ActorSystem materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| TOut2 | zero | TBD |
| Func<TOut2, TOut, TOut2> | aggregate | TBD |
| ActorSystem | materializer | TBD |
Returns
| Type | Description |
|---|---|
| Task<TOut2> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TOut2 | TBD |
RunAggregate<TOut2>(TOut2, Func<TOut2, TOut, TOut2>, IMaterializer)
Shortcut for running this Source<TOut, TMat> with a fold function.
The given function is invoked for every received element, giving it its previous
output (or the given zero value) 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.
Declaration
public Task<TOut2> RunAggregate<TOut2>(TOut2 zero, Func<TOut2, TOut, TOut2> aggregate, IMaterializer materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| TOut2 | zero | TBD |
| Func<TOut2, TOut, TOut2> | aggregate | TBD |
| IMaterializer | materializer | TBD |
Returns
| Type | Description |
|---|---|
| Task<TOut2> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TOut2 | TBD |
RunAsAsyncEnumerable(ActorSystem)
Shortcut for running this Source<TOut, TMat> as an IAsyncEnumerable<T>. The given enumerable is re-runnable but will cause a re-materialization of the stream each time. This is implemented using a SourceQueue and will buffer elements based on configured stream defaults. For custom buffers Please use RunAsAsyncEnumerableBuffer(IMaterializer, int, int)
Declaration
public IAsyncEnumerable<TOut> RunAsAsyncEnumerable(ActorSystem materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | materializer | The materializer to use for each enumeration |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TOut> | A lazy IAsyncEnumerable<T> that will run each time it is enumerated. |
RunAsAsyncEnumerable(IMaterializer)
Shortcut for running this Source<TOut, TMat> as an IAsyncEnumerable<T>. The given enumerable is re-runnable but will cause a re-materialization of the stream each time. This is implemented using a SourceQueue and will buffer elements based on configured stream defaults. For custom buffers Please use RunAsAsyncEnumerableBuffer(IMaterializer, int, int)
Declaration
public IAsyncEnumerable<TOut> RunAsAsyncEnumerable(IMaterializer materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IMaterializer | materializer | The materializer to use for each enumeration |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TOut> | A lazy IAsyncEnumerable<T> that will run each time it is enumerated. |
RunAsAsyncEnumerableBuffer(ActorSystem, int, int)
Shortcut for running this Source<TOut, TMat> as an IAsyncEnumerable<T>. The given enumerable is re-runnable but will cause a re-materialization of the stream each time. This is implemented using a SourceQueue and will buffer elements and/or backpressure, based on the buffer values provided.
Declaration
public IAsyncEnumerable<TOut> RunAsAsyncEnumerableBuffer(ActorSystem materializer, int minBuffer = 4, int maxBuffer = 16)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | materializer | The materializer to use for each enumeration |
| int | minBuffer | The minimum input buffer size |
| int | maxBuffer | The Max input buffer size. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TOut> | A lazy IAsyncEnumerable<T> that will run each time it is enumerated. |
RunAsAsyncEnumerableBuffer(IMaterializer, int, int)
Shortcut for running this Source<TOut, TMat> as an IAsyncEnumerable<T>. The given enumerable is re-runnable but will cause a re-materialization of the stream each time. This is implemented using a SourceQueue and will buffer elements and/or backpressure, based on the buffer values provided.
Declaration
public IAsyncEnumerable<TOut> RunAsAsyncEnumerableBuffer(IMaterializer materializer, int minBuffer = 4, int maxBuffer = 16)
Parameters
| Type | Name | Description |
|---|---|---|
| IMaterializer | materializer | The materializer to use for each enumeration |
| int | minBuffer | The minimum input buffer size |
| int | maxBuffer | The Max input buffer size. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<TOut> | A lazy IAsyncEnumerable<T> that will run each time it is enumerated. |
RunForeach(Action<TOut>, ActorSystem)
Shortcut for running this Source<TOut, TMat> with a foreach procedure. The given procedure is invoked for each received element. The returned Task will be completed with Success when reaching the normal end of the stream, or completed with Failure if there is a failure signaled in the stream.
Declaration
public Task RunForeach(Action<TOut> action, ActorSystem materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<TOut> | action | TBD |
| ActorSystem | materializer | TBD |
Returns
| Type | Description |
|---|---|
| Task | TBD |
RunForeach(Action<TOut>, IMaterializer)
Shortcut for running this Source<TOut, TMat> with a foreach procedure. The given procedure is invoked for each received element. The returned Task will be completed with Success when reaching the normal end of the stream, or completed with Failure if there is a failure signaled in the stream.
Declaration
public Task RunForeach(Action<TOut> action, IMaterializer materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<TOut> | action | TBD |
| IMaterializer | materializer | TBD |
Returns
| Type | Description |
|---|---|
| Task | TBD |
RunSum(Func<TOut, TOut, TOut>, ActorSystem)
Shortcut for running this Source<TOut, TMat> with a reduce function. The given function is invoked 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.
Declaration
public Task<TOut> RunSum(Func<TOut, TOut, TOut> reduce, ActorSystem materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TOut, TOut, TOut> | reduce | TBD |
| ActorSystem | materializer | TBD |
Returns
| Type | Description |
|---|---|
| Task<TOut> | TBD |
RunSum(Func<TOut, TOut, TOut>, IMaterializer)
Shortcut for running this Source<TOut, TMat> with a reduce function. The given function is invoked 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.
Declaration
public Task<TOut> RunSum(Func<TOut, TOut, TOut> reduce, IMaterializer materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TOut, TOut, TOut> | reduce | TBD |
| IMaterializer | materializer | TBD |
Returns
| Type | Description |
|---|---|
| Task<TOut> | TBD |
RunWith<TMat2>(IGraph<SinkShape<TOut>, TMat2>, ActorSystem)
Connect this Source<TOut, TMat> to a Sink<TIn, TMat> and run it. The returned value is the materialized value of the Sink<TIn, TMat> , e.g. the Reactive.Streams.IPublisher<T> of a Publisher<TIn>().
Declaration
public TMat2 RunWith<TMat2>(IGraph<SinkShape<TOut>, TMat2> sink, ActorSystem materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<SinkShape<TOut>, TMat2> | sink | TBD |
| ActorSystem | materializer | TBD |
Returns
| Type | Description |
|---|---|
| TMat2 | TBD |
Type Parameters
| Name | Description |
|---|---|
| TMat2 | TBD |
RunWith<TMat2>(IGraph<SinkShape<TOut>, TMat2>, IMaterializer)
Connect this Source<TOut, TMat> to a Sink<TIn, TMat> and run it. The returned value is the materialized value of the Sink<TIn, TMat> , e.g. the Reactive.Streams.IPublisher<T> of a Publisher<TIn>().
Declaration
public TMat2 RunWith<TMat2>(IGraph<SinkShape<TOut>, TMat2> sink, IMaterializer materializer)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<SinkShape<TOut>, TMat2> | sink | TBD |
| IMaterializer | materializer | TBD |
Returns
| Type | Description |
|---|---|
| TMat2 | TBD |
Type Parameters
| Name | Description |
|---|---|
| TMat2 | TBD |
ToMaterialized<TMat2, TMat3>(IGraph<SinkShape<TOut>, TMat2>, Func<TMat, TMat2, TMat3>)
Connect this Source<TOut, TMat> to a Sink<TIn, TMat>, concatenating the processing steps of both.
Declaration
public IRunnableGraph<TMat3> ToMaterialized<TMat2, TMat3>(IGraph<SinkShape<TOut>, TMat2> sink, Func<TMat, TMat2, TMat3> combine)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<SinkShape<TOut>, TMat2> | sink | TBD |
| Func<TMat, TMat2, TMat3> | combine | TBD |
Returns
| Type | Description |
|---|---|
| IRunnableGraph<TMat3> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TMat2 | TBD |
| TMat3 | TBD |
ToString()
TBD
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | TBD |
Overrides
| Edit this page View SourceTo<TMat2>(IGraph<SinkShape<TOut>, TMat2>)
Connect this Source<TOut, TMat> to a Sink<TIn, TMat>, concatenating the processing steps of both.
Declaration
public IRunnableGraph<TMat> To<TMat2>(IGraph<SinkShape<TOut>, TMat2> sink)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<SinkShape<TOut>, TMat2> | sink | TBD |
Returns
| Type | Description |
|---|---|
| IRunnableGraph<TMat> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TMat2 | TBD |
ViaMaterialized<TOut2, TMat2, TMat3>(IGraph<FlowShape<TOut, TOut2>, TMat2>, Func<TMat, TMat2, TMat3>)
Transform this Source<TOut, TMat> by appending the given processing steps.
The combine function is used to compose the materialized values of this flow and that
flow into the materialized value of the resulting Flow.
Declaration
public Source<TOut2, TMat3> ViaMaterialized<TOut2, TMat2, TMat3>(IGraph<FlowShape<TOut, TOut2>, TMat2> flow, Func<TMat, TMat2, TMat3> combine)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<FlowShape<TOut, TOut2>, TMat2> | flow | TBD |
| Func<TMat, TMat2, TMat3> | combine | TBD |
Returns
| Type | Description |
|---|---|
| Source<TOut2, TMat3> | TBD |
Type Parameters
| Name | Description |
|---|---|
| TOut2 | TBD |
| TMat2 | TBD |
| TMat3 | TBD |
Via<T2, TMat2>(IGraph<FlowShape<TOut, T2>, TMat2>)
Transform this Source<TOut, TMat> by appending the given processing steps. The materialized value of the combined Source<TOut, TMat> will be the materialized value of the current flow (ignoring the other flow’s value), use ViaMaterialized<TOut2, TMat2, TMat3>(IGraph<FlowShape<TOut, TOut2>, TMat2>, Func<TMat, TMat2, TMat3>) if a different strategy is needed.
Declaration
public Source<T2, TMat> Via<T2, TMat2>(IGraph<FlowShape<TOut, T2>, TMat2> flow)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph<FlowShape<TOut, T2>, TMat2> | flow | TBD |
Returns
| Type | Description |
|---|---|
| Source<T2, TMat> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T2 | TBD |
| TMat2 | TBD |
WithAttributes(Attributes)
Nests the current Source and returns a Source with the given Attributes
Declaration
public Source<TOut, TMat> WithAttributes(Attributes attributes)
Parameters
| Type | Name | Description |
|---|---|---|
| Attributes | attributes | The attributes to add |
Returns
| Type | Description |
|---|---|
| Source<TOut, TMat> | A new Source with the added attributes |
ZipN<T>(IEnumerable<Source<T, NotUsed>>)
Combine the elements of multiple streams into a stream of lists.
Declaration
public Source<IImmutableList<T>, NotUsed> ZipN<T>(IEnumerable<Source<T, NotUsed>> sources)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Source<T, NotUsed>> | sources | TBD |
Returns
| Type | Description |
|---|---|
| Source<IImmutableList<T>, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
ZipWithN<T, TOut2>(Func<IImmutableList<T>, TOut2>, IEnumerable<Source<T, NotUsed>>)
Combine the elements of multiple streams into a stream of sequences using a combiner function.
Declaration
public Source<TOut2, NotUsed> ZipWithN<T, TOut2>(Func<IImmutableList<T>, TOut2> zipper, IEnumerable<Source<T, NotUsed>> sources)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<IImmutableList<T>, TOut2> | zipper | TBD |
| IEnumerable<Source<T, NotUsed>> | sources | TBD |
Returns
| Type | Description |
|---|---|
| Source<TOut2, NotUsed> | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
| TOut2 | TBD |
Edit this page