Class EtlPipelineOperatorExtensions
- Namespace
- Wolfgang.Etl.Transformers
- Assembly
- Wolfgang.Etl.Transformers.dll
LINQ-flavored operator extension methods on Wolfgang.Etl.Abstractions.IEtlPipeline<T>. Each operator is a thin wrapper that appends one of this package's transformers to the pipeline via the core's Wolfgang.Etl.Abstractions.IEtlPipeline<T>.Through<TOut>(Wolfgang.Etl.Abstractions.ITransformAsync<T, TOut>) primitive — no iteration logic is re-implemented here.
public static class EtlPipelineOperatorExtensions
- Inheritance
-
EtlPipelineOperatorExtensions
- Inherited Members
Remarks
The pipeline core in Wolfgang.Etl.Abstractions is deliberately minimal and does not depend
on this package, so the operator surface lives here. Add a using Wolfgang.Etl.Transformers;
to light these up between the source (From(...)) and sink (To(...)) stages of a
pipeline:
await EtlPipeline
.Create()
.From(records)
.Where(r => r.Amount > 0)
.Select(r => r.Id)
.To(loader)
.RunAsync();
Methods
Buffered<T>(IEtlPipeline<T>, int)
Inserts a decoupling buffer so the upstream producer and downstream consumer run concurrently. The item type is unchanged; this batches nothing.
public static IEtlPipeline<T> Buffered<T>(this IEtlPipeline<T> pipeline, int capacity) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to buffer.
capacityintThe maximum number of items held in the buffer. Must be at least 1.
Returns
- IEtlPipeline<T>
A pipeline of the same items, produced concurrently with consumption.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineis null.
Cast<TSource, TDestination>(IEtlPipeline<TSource>)
Casts each item to TDestination, throwing on an incompatible item.
public static IEtlPipeline<TDestination> Cast<TSource, TDestination>(this IEtlPipeline<TSource> pipeline) where TSource : notnull where TDestination : notnull
Parameters
pipelineIEtlPipeline<TSource>The pipeline to cast.
Returns
- IEtlPipeline<TDestination>
A pipeline of the cast items.
Type Parameters
TSourceThe input item type. Must be non-null.
TDestinationThe target type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineis null.
Chunk<T>(IEtlPipeline<T>, int)
Batches items into fixed-size chunks.
public static IEtlPipeline<IReadOnlyList<T>> Chunk<T>(this IEtlPipeline<T> pipeline, int size) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to batch.
sizeintThe number of items per chunk. Must be at least 1.
Returns
- IEtlPipeline<IReadOnlyList<T>>
A pipeline of chunks; the final chunk may hold fewer than
sizeitems.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineis null.
DistinctBy<TSource, TKey>(IEtlPipeline<TSource>, Func<TSource, TKey>, IEqualityComparer<TKey>?)
Removes items with duplicate keys, optionally using a supplied key comparer.
public static IEtlPipeline<TSource> DistinctBy<TSource, TKey>(this IEtlPipeline<TSource> pipeline, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? comparer = null) where TSource : notnull where TKey : notnull
Parameters
pipelineIEtlPipeline<TSource>The pipeline to deduplicate.
keySelectorFunc<TSource, TKey>Extracts the key each item is deduplicated by.
comparerIEqualityComparer<TKey>The comparer used to determine key equality, or null to use Default.
Returns
- IEtlPipeline<TSource>
A pipeline keeping the first item seen for each distinct key.
Type Parameters
TSourceThe item type. Must be non-null.
TKeyThe key type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorkeySelectoris null.
Distinct<T>(IEtlPipeline<T>, IEqualityComparer<T>?)
Removes duplicate items, optionally using a supplied comparer.
public static IEtlPipeline<T> Distinct<T>(this IEtlPipeline<T> pipeline, IEqualityComparer<T>? comparer = null) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to deduplicate.
comparerIEqualityComparer<T>The comparer used to determine equality, or null to use Default.
Returns
- IEtlPipeline<T>
A pipeline with duplicate items removed, preserving first-seen order.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineis null.
Log<T>(IEtlPipeline<T>, Func<T, string>, Action<string>)
Writes a log line per item and passes the item through unchanged — a Tap<T>(IEtlPipeline<T>, Action<T>)
bound to a formatter and a sink. Deliberately dependency-free: it takes a delegate sink rather than
referencing Microsoft.Extensions.Logging, so bridge to an ILogger at the call site if desired.
public static IEtlPipeline<T> Log<T>(this IEtlPipeline<T> pipeline, Func<T, string> format, Action<string> sink) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to observe.
formatFunc<T, string>Produces the log message for an item.
sinkAction<string>Receives each formatted message (e.g.
Console.WriteLineormsg => logger.LogInformation(msg)).
Returns
- IEtlPipeline<T>
A pipeline yielding the same items, in the same order, logging one message per item.
Type Parameters
TThe item type. Must be non-null.
Examples
await EtlPipeline
.Create()
.From(records)
.Log(r => $"processing {r.Id}", Console.WriteLine)
.To(loader)
.RunAsync();
Exceptions
- ArgumentNullException
pipeline,format, orsinkis null.
OfType<TSource, TDestination>(IEtlPipeline<TSource>)
Passes through only the items assignable to TDestination.
public static IEtlPipeline<TDestination> OfType<TSource, TDestination>(this IEtlPipeline<TSource> pipeline) where TSource : notnull where TDestination : notnull
Parameters
pipelineIEtlPipeline<TSource>The pipeline to filter by type.
Returns
- IEtlPipeline<TDestination>
A pipeline of the items that are of type
TDestination.
Type Parameters
TSourceThe input item type. Must be non-null.
TDestinationThe type to filter to. Must be non-null.
Exceptions
- ArgumentNullException
pipelineis null.
SelectMany<TSource, TDestination>(IEtlPipeline<TSource>, Func<TSource, IAsyncEnumerable<TDestination>>)
Fans each item out to an asynchronous sequence and flattens the results.
public static IEtlPipeline<TDestination> SelectMany<TSource, TDestination>(this IEtlPipeline<TSource> pipeline, Func<TSource, IAsyncEnumerable<TDestination>> selector) where TSource : notnull where TDestination : notnull
Parameters
pipelineIEtlPipeline<TSource>The pipeline to fan out.
selectorFunc<TSource, IAsyncEnumerable<TDestination>>Maps each item to an asynchronous sequence of results.
Returns
- IEtlPipeline<TDestination>
A pipeline of the flattened items.
Type Parameters
TSourceThe input item type. Must be non-null.
TDestinationThe flattened item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorselectoris null.
SelectMany<TSource, TDestination>(IEtlPipeline<TSource>, Func<TSource, IEnumerable<TDestination>>)
Fans each item out to a synchronous sequence and flattens the results.
public static IEtlPipeline<TDestination> SelectMany<TSource, TDestination>(this IEtlPipeline<TSource> pipeline, Func<TSource, IEnumerable<TDestination>> selector) where TSource : notnull where TDestination : notnull
Parameters
pipelineIEtlPipeline<TSource>The pipeline to fan out.
selectorFunc<TSource, IEnumerable<TDestination>>Maps each item to a sequence of results.
Returns
- IEtlPipeline<TDestination>
A pipeline of the flattened items.
Type Parameters
TSourceThe input item type. Must be non-null.
TDestinationThe flattened item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorselectoris null.
Select<TSource, TDestination>(IEtlPipeline<TSource>, Func<TSource, ValueTask<TDestination>>)
Projects each item with an asynchronous selector.
public static IEtlPipeline<TDestination> Select<TSource, TDestination>(this IEtlPipeline<TSource> pipeline, Func<TSource, ValueTask<TDestination>> selector) where TSource : notnull where TDestination : notnull
Parameters
pipelineIEtlPipeline<TSource>The pipeline to project.
selectorFunc<TSource, ValueTask<TDestination>>The asynchronous projection applied to each item.
Returns
- IEtlPipeline<TDestination>
A pipeline of the projected items.
Type Parameters
TSourceThe input item type. Must be non-null.
TDestinationThe projected item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorselectoris null.
Select<TSource, TDestination>(IEtlPipeline<TSource>, Func<TSource, TDestination>)
Projects each item with a synchronous selector.
public static IEtlPipeline<TDestination> Select<TSource, TDestination>(this IEtlPipeline<TSource> pipeline, Func<TSource, TDestination> selector) where TSource : notnull where TDestination : notnull
Parameters
pipelineIEtlPipeline<TSource>The pipeline to project.
selectorFunc<TSource, TDestination>The projection applied to each item.
Returns
- IEtlPipeline<TDestination>
A pipeline of the projected items.
Type Parameters
TSourceThe input item type. Must be non-null.
TDestinationThe projected item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorselectoris null.
SkipWhile<T>(IEtlPipeline<T>, Func<T, bool>)
Skips items while a synchronous predicate holds, then yields the rest.
public static IEtlPipeline<T> SkipWhile<T>(this IEtlPipeline<T> pipeline, Func<T, bool> predicate) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to skip within.
predicateFunc<T, bool>Skipping continues while this returns true.
Returns
- IEtlPipeline<T>
A pipeline yielding everything from the first item that fails
predicateonward.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorpredicateis null.
SkipWhile<T>(IEtlPipeline<T>, Func<T, ValueTask<bool>>)
Skips items while an asynchronous predicate holds, then yields the rest.
public static IEtlPipeline<T> SkipWhile<T>(this IEtlPipeline<T> pipeline, Func<T, ValueTask<bool>> predicate) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to skip within.
predicateFunc<T, ValueTask<bool>>Skipping continues while this returns true.
Returns
- IEtlPipeline<T>
A pipeline yielding everything from the first item that fails
predicateonward.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorpredicateis null.
Skip<T>(IEtlPipeline<T>, int)
Skips the first count items, then yields the rest.
public static IEtlPipeline<T> Skip<T>(this IEtlPipeline<T> pipeline, int count) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to skip within.
countintThe number of leading items to skip. Must be non-negative.
Returns
- IEtlPipeline<T>
A pipeline yielding the items after the first
count.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineis null.
TakeWhile<T>(IEtlPipeline<T>, Func<T, bool>)
Yields items while a synchronous predicate holds, then stops.
public static IEtlPipeline<T> TakeWhile<T>(this IEtlPipeline<T> pipeline, Func<T, bool> predicate) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to truncate.
predicateFunc<T, bool>Yielding continues while this returns true.
Returns
- IEtlPipeline<T>
A pipeline yielding the leading run of items satisfying
predicate.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorpredicateis null.
TakeWhile<T>(IEtlPipeline<T>, Func<T, ValueTask<bool>>)
Yields items while an asynchronous predicate holds, then stops.
public static IEtlPipeline<T> TakeWhile<T>(this IEtlPipeline<T> pipeline, Func<T, ValueTask<bool>> predicate) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to truncate.
predicateFunc<T, ValueTask<bool>>Yielding continues while this returns true.
Returns
- IEtlPipeline<T>
A pipeline yielding the leading run of items satisfying
predicate.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorpredicateis null.
Take<T>(IEtlPipeline<T>, int)
Yields only the first count items, then stops.
public static IEtlPipeline<T> Take<T>(this IEtlPipeline<T> pipeline, int count) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to truncate.
countintThe maximum number of items to yield. Must be non-negative.
Returns
- IEtlPipeline<T>
A pipeline yielding at most
countitems.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineis null.
Tap<T>(IEtlPipeline<T>, Action<T>)
Runs a synchronous side effect on each item and passes the item through unchanged — an observability "tap" point (logging, metrics, debugging) that does not alter the stream's shape.
public static IEtlPipeline<T> Tap<T>(this IEtlPipeline<T> pipeline, Action<T> onItem) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to observe.
onItemAction<T>The side effect to run for each item before it flows on.
Returns
- IEtlPipeline<T>
A pipeline yielding the same items, in the same order, with
onIteminvoked per item.
Type Parameters
TThe item type. Must be non-null.
Examples
await EtlPipeline
.Create()
.From(records)
.Tap(r => Console.WriteLine($"seen {r.Id}"))
.To(loader)
.RunAsync();
Exceptions
- ArgumentNullException
pipelineoronItemis null.
Tap<T>(IEtlPipeline<T>, Func<T, ValueTask>)
Runs an asynchronous side effect on each item and passes the item through unchanged — an observability "tap" point that does not alter the stream's shape.
public static IEtlPipeline<T> Tap<T>(this IEtlPipeline<T> pipeline, Func<T, ValueTask> onItem) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to observe.
onItemFunc<T, ValueTask>The asynchronous side effect to run for each item before it flows on.
Returns
- IEtlPipeline<T>
A pipeline yielding the same items, in the same order, with
onItemawaited per item.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineoronItemis null.
Throttle<T>(IEtlPipeline<T>, TimeSpan)
Paces the pipeline so successive items are yielded at least minInterval apart,
without changing the stream's shape or order — rate-limiting for a downstream sink that must not be
hit too fast. The first item is not delayed; pacing is adaptive (a consumer that was already slow is
not delayed further) and observes the pipeline's cancellation token.
public static IEtlPipeline<T> Throttle<T>(this IEtlPipeline<T> pipeline, TimeSpan minInterval) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to pace.
minIntervalTimeSpanThe minimum time between successive items. Zero is a pass-through.
Returns
- IEtlPipeline<T>
A pipeline yielding the same items, in the same order, paced apart.
Type Parameters
TThe item type. Must be non-null.
Examples
await EtlPipeline
.Create()
.From(records)
.Throttle(TimeSpan.FromMilliseconds(200)) // at most ~5 items/second
.To(loader)
.RunAsync();
Exceptions
- ArgumentNullException
pipelineis null.- ArgumentOutOfRangeException
minIntervalis negative.
Where<T>(IEtlPipeline<T>, Func<T, bool>)
Filters the pipeline to items that satisfy a synchronous predicate.
public static IEtlPipeline<T> Where<T>(this IEtlPipeline<T> pipeline, Func<T, bool> predicate) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to filter.
predicateFunc<T, bool>The predicate an item must satisfy to be kept.
Returns
- IEtlPipeline<T>
A pipeline yielding only the items for which
predicatereturns true.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorpredicateis null.
Where<T>(IEtlPipeline<T>, Func<T, ValueTask<bool>>)
Filters the pipeline to items that satisfy an asynchronous predicate.
public static IEtlPipeline<T> Where<T>(this IEtlPipeline<T> pipeline, Func<T, ValueTask<bool>> predicate) where T : notnull
Parameters
pipelineIEtlPipeline<T>The pipeline to filter.
predicateFunc<T, ValueTask<bool>>The asynchronous predicate an item must satisfy to be kept.
Returns
- IEtlPipeline<T>
A pipeline yielding only the items for which
predicatereturns true.
Type Parameters
TThe item type. Must be non-null.
Exceptions
- ArgumentNullException
pipelineorpredicateis null.