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
sourceIMappedQuery<T>The mapped query to read.
targetITargetBlock<T>The block to send to.
stallTimeoutTimeSpanThe longest the block may take no row while the reader is held. Required; passed to
Stream.cancellationTokenCancellationTokenCancels the pass.
Returns
Type Parameters
TThe 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
sourceortargetis null.- ArgumentOutOfRangeException
stallTimeoutis zero or negative and not InfiniteTimeSpan.- OperationCanceledException
cancellationTokenis 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
sourceIMappedQuery<T>The mapped query to read.
targetITargetBlock<T>The block to send to.
stallTimeoutTimeSpanThe longest the block may take no row while the reader is held. Required; passed to
Stream.completebooltrue to complete the block when the pass ends, or to fault it with the exception that ended the pass, a cancel included.
cancellationTokenCancellationTokenCancels the pass.
Returns
Type Parameters
TThe 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
sourceortargetis null.- ArgumentOutOfRangeException
stallTimeoutis zero or negative and not InfiniteTimeSpan.- OperationCanceledException
cancellationTokenis already canceled.- TimeoutException
The block took no row for
stallTimeout.