Table of Contents

Class PipelineExtensions

Namespace
DotnetKit.DataflowBuilder
Assembly
DotnetKit.DataflowBuilder.dll

Provides extension methods for ingesting data streams into IPipeline<TSource> instances.

public static class PipelineExtensions
Inheritance
PipelineExtensions
Inherited Members

Methods

SendAllAsync<TSource>(IPipeline<TSource>, IAsyncEnumerable<TSource>, bool, CancellationToken)

Asynchronously streams all elements from an IAsyncEnumerable<T> into the pipeline.

public static Task SendAllAsync<TSource>(this IPipeline<TSource> pipeline, IAsyncEnumerable<TSource> source, bool completeAfterSend = false, CancellationToken cancellationToken = default)

Parameters

pipeline IPipeline<TSource>

The target pipeline.

source IAsyncEnumerable<TSource>

The asynchronous stream of elements to send.

completeAfterSend bool

Whether to automatically call CompleteAsync() after all items are dispatched.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task

A task that completes when all elements have been sent (and completed, if completeAfterSend is true).

Type Parameters

TSource

The type of elements accepted by the pipeline.

Exceptions

ArgumentNullException

Thrown if pipeline or source is null.

SendAllAsync<TSource>(IPipeline<TSource>, IEnumerable<TSource>, bool, CancellationToken)

Asynchronously sends all elements from an IEnumerable<T> into the pipeline.

public static Task SendAllAsync<TSource>(this IPipeline<TSource> pipeline, IEnumerable<TSource> source, bool completeAfterSend = false, CancellationToken cancellationToken = default)

Parameters

pipeline IPipeline<TSource>

The target pipeline.

source IEnumerable<TSource>

The sequence of elements to send.

completeAfterSend bool

Whether to automatically call CompleteAsync() after all items are dispatched.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task

A task that completes when all elements have been sent (and completed, if completeAfterSend is true).

Type Parameters

TSource

The type of elements accepted by the pipeline.

Exceptions

ArgumentNullException

Thrown if pipeline or source is null.

SendFromChannelAsync<TSource>(IPipeline<TSource>, ChannelReader<TSource>, bool, CancellationToken)

Asynchronously reads all elements from a ChannelReader<T> and sends them into the pipeline until the channel is completed.

public static Task SendFromChannelAsync<TSource>(this IPipeline<TSource> pipeline, ChannelReader<TSource> channelReader, bool completeAfterSend = true, CancellationToken cancellationToken = default)

Parameters

pipeline IPipeline<TSource>

The target pipeline.

channelReader ChannelReader<TSource>

The channel reader producing items.

completeAfterSend bool

Whether to automatically complete the pipeline once the channel completes. Defaults to true.

cancellationToken CancellationToken

A token to monitor for cancellation requests.

Returns

Task

A task that completes when all channel items have been forwarded to the pipeline.

Type Parameters

TSource

The type of elements accepted by the pipeline.

Exceptions

ArgumentNullException

Thrown if pipeline or channelReader is null.