Method ToChannelHoldingConnection
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Channel.dll
ToChannelHoldingConnection<T>(IMappedQuery<T>, Channel<T>, TimeSpan, CancellationToken)
Reads the query one row at a time and writes each row to a channel you own, leaving the channel open.
public static ValueTask<long> ToChannelHoldingConnection<T>(this IMappedQuery<T> source, Channel<T> channel, TimeSpan stallTimeout, CancellationToken cancellationToken = default)
Parameters
sourceIMappedQuery<T>The mapped query to read.
channelChannel<T>The channel to write to.
stallTimeoutTimeSpanThe longest the channel may make no room while the reader is held. Required; passed to
Stream. The wait for room before the command runs is not timed.cancellationTokenCancellationTokenCancels the pass.
Returns
Type Parameters
TThe type of each row.
Remarks
Holds the reader and the connection open for each row: while the channel is full,
the next row is not pulled and the connection stays open until
stallTimeout expires (never, with InfiniteTimeSpan).
Use ToChannel<T>(IMappedQuery<T>, Channel<T>, CancellationToken),
which frees the connection first, unless the rows must be pulled one at a time;
otherwise it behaves as that member.
See StreamBuffered(TimeSpan, int, CancellationToken) (with a buffer of one row) for the stall rules.
Exceptions
- ArgumentNullException
sourceorchannelis null.- ArgumentOutOfRangeException
stallTimeoutis zero or negative and not InfiniteTimeSpan.- OperationCanceledException
cancellationTokenis already canceled.- TimeoutException
The channel made no room for
stallTimeout.
ToChannelHoldingConnection<T>(IMappedQuery<T>, Channel<T>, TimeSpan, bool, CancellationToken)
Reads the query one row at a time and writes each row to a channel you own, leaving the channel open.
public static ValueTask<long> ToChannelHoldingConnection<T>(this IMappedQuery<T> source, Channel<T> channel, TimeSpan stallTimeout, bool complete, CancellationToken cancellationToken = default)
Parameters
sourceIMappedQuery<T>The mapped query to read.
channelChannel<T>The channel to write to.
stallTimeoutTimeSpanThe longest the channel may make no room while the reader is held. Required; passed to
Stream. The wait for room before the command runs is not timed.completebooltrue to complete the channel when the pass ends, with the exception that ended it if there was one.
cancellationTokenCancellationTokenCancels the pass.
Returns
Type Parameters
TThe type of each row.
Remarks
Holds the reader and the connection open for each row: while the channel is full,
the next row is not pulled and the connection stays open until
stallTimeout expires (never, with InfiniteTimeSpan).
Use ToChannel<T>(IMappedQuery<T>, Channel<T>, CancellationToken),
which frees the connection first, unless the rows must be pulled one at a time;
otherwise it behaves as that member.
See StreamBuffered(TimeSpan, int, CancellationToken) (with a buffer of one row) for the stall rules.
Exceptions
- ArgumentNullException
sourceorchannelis null.- ArgumentOutOfRangeException
stallTimeoutis zero or negative and not InfiniteTimeSpan.- OperationCanceledException
cancellationTokenis already canceled.- TimeoutException
The channel made no room for
stallTimeout.
ToChannelHoldingConnection<T>(IMappedQuery<T>, ChannelWriter<T>, TimeSpan, CancellationToken)
Reads the query one row at a time and writes each row to a channel you own, leaving the channel open.
public static ValueTask<long> ToChannelHoldingConnection<T>(this IMappedQuery<T> source, ChannelWriter<T> writer, TimeSpan stallTimeout, CancellationToken cancellationToken = default)
Parameters
sourceIMappedQuery<T>The mapped query to read.
writerChannelWriter<T>The writer to write to.
stallTimeoutTimeSpanThe longest the writer may make no room while the reader is held. Required; passed to
Stream. The wait for room before the command runs is not timed.cancellationTokenCancellationTokenCancels the pass.
Returns
Type Parameters
TThe type of each row.
Remarks
Holds the reader and the connection open for each row: while the channel is full,
the next row is not pulled and the connection stays open until
stallTimeout expires (never, with InfiniteTimeSpan).
Use ToChannel<T>(IMappedQuery<T>, Channel<T>, CancellationToken),
which frees the connection first, unless the rows must be pulled one at a time;
otherwise it behaves as that member.
See StreamBuffered(TimeSpan, int, CancellationToken) (with a buffer of one row) for the stall rules.
Exceptions
- ArgumentNullException
sourceorchannelis null.- ArgumentOutOfRangeException
stallTimeoutis zero or negative and not InfiniteTimeSpan.- OperationCanceledException
cancellationTokenis already canceled.- TimeoutException
The channel made no room for
stallTimeout.
ToChannelHoldingConnection<T>(IMappedQuery<T>, ChannelWriter<T>, TimeSpan, bool, CancellationToken)
Reads the query one row at a time and writes each row to a channel you own, leaving the channel open.
public static ValueTask<long> ToChannelHoldingConnection<T>(this IMappedQuery<T> source, ChannelWriter<T> writer, TimeSpan stallTimeout, bool complete, CancellationToken cancellationToken = default)
Parameters
sourceIMappedQuery<T>The mapped query to read.
writerChannelWriter<T>The writer to write to.
stallTimeoutTimeSpanThe longest the writer may make no room while the reader is held. Required; passed to
Stream. The wait for room before the command runs is not timed.completebooltrue to complete the writer when the pass ends, with the exception that ended it if there was one.
cancellationTokenCancellationTokenCancels the pass.
Returns
Type Parameters
TThe type of each row.
Remarks
Holds the reader and the connection open for each row: while the channel is full,
the next row is not pulled and the connection stays open until
stallTimeout expires (never, with InfiniteTimeSpan).
Use ToChannel<T>(IMappedQuery<T>, Channel<T>, CancellationToken),
which frees the connection first, unless the rows must be pulled one at a time;
otherwise it behaves as that member.
See StreamBuffered(TimeSpan, int, CancellationToken) (with a buffer of one row) for the stall rules.
Exceptions
- ArgumentNullException
sourceorchannelis null.- ArgumentOutOfRangeException
stallTimeoutis zero or negative and not InfiniteTimeSpan.- OperationCanceledException
cancellationTokenis already canceled.- TimeoutException
The channel made no room for
stallTimeout.