Skip to main content

new_batcher

Function new_batcher 

Source
pub fn new_batcher<I, T, E>(
    items: I,
    stats: Arc<BatchIteratorConnectionStats>,
    mode: StreamMode,
) -> FormattedStream
where I: Stream<Item = Result<T, E>> + Send + 'static, T: Into<FormattedContent> + Send, E: Into<AccessorError> + Send,
Expand description

Make a new FormattedContentBatcher with a chunking strategy depending on stream mode.

In snapshot mode, batched items will not be flushed to the client until the batch is complete, the underlying stream has terminated, or SNAPSHOT_TIMEOUT has passed since the first item was discovered (in order to prevent client starvation).

In subscribe or snapshot-then-subscribe mode, batched items will be flushed whenever the underlying stream is pending, ensuring clients always receive latest results.