Open.ChannelExtensions 3.3.0

There is a newer version of this package available.
See the version list below for details.
Install-Package Open.ChannelExtensions -Version 3.3.0
dotnet add package Open.ChannelExtensions --version 3.3.0
<PackageReference Include="Open.ChannelExtensions" Version="3.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Open.ChannelExtensions --version 3.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Open.ChannelExtensions, 3.3.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Open.ChannelExtensions as a Cake Addin
#addin nuget:?package=Open.ChannelExtensions&version=3.3.0

// Install Open.ChannelExtensions as a Cake Tool
#tool nuget:?package=Open.ChannelExtensions&version=3.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Open.ChannelExtensions

A set of extensions for optimizing/simplifying System.Threading.Channels usage.

Click here for detailed documentation.

Highlights

Being able to define an asynchronous pipeline with best practice usage using simple expressive syntax:

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.
    });
await source /* IEnumerable<T> */
    .ToChannel(boundedSize: 10, singleReader: true)
    .PipeAsync(asyncTransform01, /* capacity */ 5)
    .Pipe(
        maxConcurrency: 2,
        capacity: 3,
        transform: transform02)
    .ReadAll(finalTransformedValue => {
        // Do something with each final value.
    });

Examples

Reading (until the channel is closed)

One by one read each entry from the channel
await channel.ReadAll(
    entry => { /* Processing Code */ });
await channel.ReadAll(
    (entry, index) => { /* Processing Code */ });
await channel.ReadAllAsync(
    async entry => { await /* Processing Code */ });
await channel.ReadAllAsync(
    async (entry, index) => { await /* Processing Code */ });
Read concurrently each entry from the channel
await channel.ReadAllConcurrently(
    maxConcurrency,
    entry => { /* Processing Code */ });
await channel.ReadAllConcurrentlyAsync(
    maxConcurrency,
    async entry => { await /* Processing Code */ });

Writing

If complete is true, the channel will be closed when the source is empty.

Dump a source enumeration into the channel
// source can be any IEnumerable<T>.
await channel.WriteAll(source, complete: true);
// source can be any IEnumerable<Task<T>> or IEnumerable<ValueTask<T>>.
await channel.WriteAllAsync(source, complete: true);
Synchronize reading from the source and process the results concurrently
// source can be any IEnumerable<Task<T>> or IEnumerable<ValueTask<T>>.
await channel.WriteAllConcurrentlyAsync(
    maxConcurrency, source, complete: true);

Pipelining / Transforming

Transform and buffer entries
// Transform values in a source channel to new unbounded channel.
var transformed = channel.Pipe(
    async value => /* transformation */);
// Transform values in a source channel to new unbounded channel with a max concurrency of X.
const X = 4;
var transformed = channel.Pipe(
    X, async value => /* transformation */);
// Transform values in a source channel to new bounded channel bound of N entries.
const N = 5;
var transformed = channel.Pipe(
    async value => /* transformation */, N);
// Transform values in a source channel to new bounded channel bound of N entries with a max concurrency of X.
const X = 4;
const N = 5;
var transformed = channel.Pipe(
    X, async value => /* transformation */, N);

// or
transformed = channel.Pipe(
    maxConcurrency: X,
    capacity: N,
    transform: async value => /* transformation */);

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Open.ChannelExtensions:

Package Downloads
Open.Database.Extensions.Channel

Database extensions for pipelining data through channels. Includes Open.Database.Extensions.Core.

DataPipe.Core

Provides AWS support to the DataPipe platform. Reference this package if you need to read or write to S3 from a data pipe script

Resistance.Postgres

.NET toolkit for PostgreSQL

Pype.Background.Channels

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Open.ChannelExtensions:

Repository Stars
WolvenKit/WolvenKit
Mod editor/creator for RED Engine games. The point is to have an all in one tool for creating mods for the games made with the engine.
Version Downloads Last updated
5.0.0 3,442 6/16/2021
3.5.0 40,168 7/16/2020
3.4.0 3,401 6/3/2020
3.3.2 225 6/1/2020
3.3.1 242 5/14/2020
3.3.0 2,893 2/19/2020
2.6.0 229 10/20/2019