archivist_lib::formatter

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 or the underlying stream has terminated.

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