Table of Contents

Method ToTargetBlockHoldingConnection

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Dataflow.dll

ToTargetBlockHoldingConnection<T>(IMappedQuery<T>, ITargetBlock<T>, TimeSpan, CancellationToken)

Reads the query one row at a time and sends each row to a block you own, leaving the block open.

public static ValueTask<long> ToTargetBlockHoldingConnection<T>(this IMappedQuery<T> source, ITargetBlock<T> target, TimeSpan stallTimeout, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

target ITargetBlock<T>

The block to send to.

stallTimeout TimeSpan

The longest the block may take no row while the reader is held. Required; passed to Stream.

cancellationToken CancellationToken

Cancels the pass.

Returns

ValueTask<long>

The number of rows the block accepted.

Type Parameters

T

The type of each row.

Remarks

Pulls StreamBuffered(TimeSpan, int, CancellationToken) with a buffer of one row: the reader and the connection are held for each row, and while the block is full they stay held until it takes the row or stallTimeout expires; with InfiniteTimeSpan nothing ends that wait. To close the connection as soon as the rows are read, use ToTargetBlock<T>(IMappedQuery<T>, ITargetBlock<T>, CancellationToken), which this otherwise matches. See Stream for when to use this and what stallTimeout does.

Exceptions

ArgumentNullException

source or target is null.

ArgumentOutOfRangeException

stallTimeout is zero or negative and not InfiniteTimeSpan.

OperationCanceledException

cancellationToken is already canceled.

TimeoutException

The block took no row for stallTimeout.

ToTargetBlockHoldingConnection<T>(IMappedQuery<T>, ITargetBlock<T>, TimeSpan, bool, CancellationToken)

Reads the query one row at a time and sends each row to a block you own, completing the block when the pass ends if complete is true.

public static ValueTask<long> ToTargetBlockHoldingConnection<T>(this IMappedQuery<T> source, ITargetBlock<T> target, TimeSpan stallTimeout, bool complete, CancellationToken cancellationToken = default)

Parameters

source IMappedQuery<T>

The mapped query to read.

target ITargetBlock<T>

The block to send to.

stallTimeout TimeSpan

The longest the block may take no row while the reader is held. Required; passed to Stream.

complete bool

true to complete the block when the pass ends, or to fault it with the exception that ended the pass, a cancel included.

cancellationToken CancellationToken

Cancels the pass.

Returns

ValueTask<long>

The number of rows the block accepted.

Type Parameters

T

The type of each row.

Remarks

Pulls StreamBuffered(TimeSpan, int, CancellationToken) with a buffer of one row: the reader and the connection are held for each row, and while the block is full they stay held until it takes the row or stallTimeout expires; with InfiniteTimeSpan nothing ends that wait. To close the connection as soon as the rows are read, use ToTargetBlock<T>(IMappedQuery<T>, ITargetBlock<T>, bool, CancellationToken). See Stream for when to use this and what stallTimeout does. complete works as for that member.

Exceptions

ArgumentNullException

source or target is null.

ArgumentOutOfRangeException

stallTimeout is zero or negative and not InfiniteTimeSpan.

OperationCanceledException

cancellationToken is already canceled.

TimeoutException

The block took no row for stallTimeout.