Class ChainTransformerWithCancellation<TSource, TIntermediate, TDestination>

Namespace
Wolfgang.Etl.Transformers
Assembly
Wolfgang.Etl.Transformers.dll

Combines two cancellation-aware transformers into a single Wolfgang.Etl.Abstractions.ITransformWithCancellationAsync<TSource, TDestination>: items flow through the first, then through the second, and a single CancellationToken supplied to the chain is propagated to both stages.

public sealed class ChainTransformerWithCancellation<TSource, TIntermediate, TDestination> : ITransformWithCancellationAsync<TSource, TDestination>, ITransformAsync<TSource, TDestination> where TSource : notnull where TIntermediate : notnull where TDestination : notnull

Type Parameters

TSource

The input type of the chain (the input type of the first transformer). Must be non-null.

TIntermediate

The output type of the first transformer and input type of the second. Must be non-null.

TDestination

The output type of the chain (the output type of the second transformer). Must be non-null.

Inheritance
ChainTransformerWithCancellation<TSource, TIntermediate, TDestination>
Implements
ITransformWithCancellationAsync<TSource, TDestination>
ITransformAsync<TSource, TDestination>
Inherited Members
Extension Methods

Remarks

This is the cancellation-aware sibling of ChainTransformer<TSource, TIntermediate, TDestination>. Use it when both inner transformers implement Wolfgang.Etl.Abstractions.ITransformWithCancellationAsync<TSource, TDestination> and you want a token passed to the chain to flow into both stages.

For chains longer than two stages, prefer the Then<TSource, TIntermediate, TDestination>(ITransformWithCancellationAsync<TSource, TIntermediate>, ITransformWithCancellationAsync<TIntermediate, TDestination>) overload, which lets the C# compiler infer all type parameters and pick this class automatically when both arguments support cancellation.

Progress reporting is intentionally not supported at the chain level - two transformers almost always declare different TProgress types and there is no general way to combine them. Cancellation is different: CancellationToken is a single concrete type, so propagating it to both stages is unambiguous.

The chain itself adds no per-item state-machine wrapping; TransformAsync in both overloads composes the inner transformers' enumerables directly.

Constructors

ChainTransformerWithCancellation(ITransformWithCancellationAsync<TSource, TIntermediate>, ITransformWithCancellationAsync<TIntermediate, TDestination>)

Initializes a new instance with the two cancellation-aware transformers that make up the chain.

public ChainTransformerWithCancellation(ITransformWithCancellationAsync<TSource, TIntermediate> first, ITransformWithCancellationAsync<TIntermediate, TDestination> second)

Parameters

first ITransformWithCancellationAsync<TSource, TIntermediate>

The first transformer; consumes TSource items and produces TIntermediate items.

second ITransformWithCancellationAsync<TIntermediate, TDestination>

The second transformer; consumes TIntermediate items and produces TDestination items.

Exceptions

ArgumentNullException

first or second is null.

Methods

TransformAsync(IAsyncEnumerable<TSource>)

Asynchronously yields each item from items after passing it through the first transformer and then the second.

public IAsyncEnumerable<TDestination> TransformAsync(IAsyncEnumerable<TSource> items)

Parameters

items IAsyncEnumerable<TSource>

The asynchronous source sequence.

Returns

IAsyncEnumerable<TDestination>

An asynchronous sequence of the items produced by the second transformer.

Exceptions

ArgumentNullException

items is null.

TransformAsync(IAsyncEnumerable<TSource>, CancellationToken)

Asynchronously yields each item from items after passing it through the first transformer and then the second, propagating token to both stages.

public IAsyncEnumerable<TDestination> TransformAsync(IAsyncEnumerable<TSource> items, CancellationToken token)

Parameters

items IAsyncEnumerable<TSource>

The asynchronous source sequence.

token CancellationToken

The token observed by both stages of the chain.

Returns

IAsyncEnumerable<TDestination>

An asynchronous sequence of the items produced by the second transformer.

Exceptions

ArgumentNullException

items is null.