Build an asynchronous pipeline with Open.ChannelExtensions
masterYou can define expressive, asynchronous processing pipelines by chaining extensions on a System.Threading.Channels.Channel. This allows you to source data, apply transformations with controlled concurrency and capacity, and consume the final results in a single fluent statement.
Common pipeline steps include:
SourceAsync: Populates a channel from anIEnumerable<Task<T>>.PipeAsync: Performs asynchronous transformations withmaxConcurrencyandcapacitysettings.Pipe: Performs synchronous transformations withcapacitysettings.ReadAllAsync: Consumes the final values from the pipeline.
await Channel
.CreateBounded<T>(10)
.SourceAsync(source /* IEnumerable<Task<T>> */)
.PipeAsync(
maxConcurrency: 2,
capacity: 5,
transform: asyncTransform01)
.Pipe(transform02, /* capacity */ 3)
.ReadAllAsync(finalTransformedValue => {
// Do something async with each final value.
});