Table of Contents

Class DataFlowPipelineBuilder

Namespace
DotnetKit.DataflowBuilder
Assembly
DotnetKit.DataflowBuilder.dll

Provides factory methods for initiating fluent dataflow pipelines from single or multiple data sources.

public static class DataFlowPipelineBuilder
Inheritance
DataFlowPipelineBuilder
Inherited Members

Methods

FromSource<TSource>(int, CancellationToken)

Creates a fluent pipeline builder with an initial buffer block accepting items of type TSource.

public static IFluentBuilder<ISourceBlock<TSource>, IPipelineBuilder<TSource>> FromSource<TSource>(int sourceBufferSize = 1, CancellationToken cancellationToken = default)

Parameters

sourceBufferSize int

The bounded capacity of the entry buffer block. Defaults to 1.

cancellationToken CancellationToken

An optional token to propagate cancellation across the pipeline.

Returns

IFluentBuilder<ISourceBlock<TSource>, IPipelineBuilder<TSource>>

A fluent builder interface configured with an IPipelineBuilder<TSource> context.

Type Parameters

TSource

The type of elements accepted at the entrance of the pipeline.

Examples

var pipeline = DataFlowPipelineBuilder.FromSource<int>(sourceBufferSize: 10)
    .Process(x => x * 2)
    .ToTarget(Console.WriteLine)
    .Build();

FromSources<TSource1, TSource2>(int, CancellationToken)

Creates a fluent multi-source pipeline builder with two initial buffer blocks joined into pairs.

public static IFluentBuilder<ISourceBlock<Tuple<TSource1, TSource2>>, DataFlowPipelineBuilder<TSource1, TSource2>> FromSources<TSource1, TSource2>(int sourceBufferSize = 1, CancellationToken cancellationToken = default)

Parameters

sourceBufferSize int

The bounded capacity for each source buffer block. Defaults to 1.

cancellationToken CancellationToken

An optional token to propagate cancellation across the pipeline.

Returns

IFluentBuilder<ISourceBlock<Tuple<TSource1, TSource2>>, DataFlowPipelineBuilder<TSource1, TSource2>>

A fluent builder interface configured with a multi-source builder context.

Type Parameters

TSource1

The type of elements accepted by the first pipeline source.

TSource2

The type of elements accepted by the second pipeline source.

Examples

var pipeline = DataFlowPipelineBuilder.FromSources<string, int>()
    .Process(pair => $"{pair.Item1}: {pair.Item2}")
    .ToTarget(Console.WriteLine)
    .Build();