Struct multistream_batch::multi_buf_batch::MultiBufBatch[][src]

pub struct MultiBufBatch<K: Debug + Ord + Hash, I: Debug> { /* fields omitted */ }
Expand description

Collects items into multiple batches based on stream key. A batch may become ready after collecting max_size number of items or until max_duration has elapsed since first item was appended to the batch.

Batch item buffers are cached and reused to avoid allocations.

This base implementation does not handle actual awaiting for batch duration timeout.

Implementations

Crates new instance with given maximum batch size (max_size) and maximum duration (max_duration) that batch can last since first item appended to it.

Panics if max_size == 0.

Checks if batch has reached one of its limits.

Returns:

  • PollResult::Ready(K) - batch for stream key K has reached one of its limit and is ready to be consumed,
  • PollResult::NotReady(None) - batch is not ready yet and has no items appeded yet,
  • PollResult::NotReady(Some(duration)) - batch is not ready yet but it will be ready after time duration due to duration limit.

Appends item to batch with given stream key.

It is an contract error to append batch that is ready according to self.poll().

Panics if batch has already reached its max_size limit.

Lists keys of outstanding batches.

Starts new batch dropping all buffered items.

Consumes batch by draining items from internal buffer.

Flushes all outstanding batches starting from oldest.

Returns slice of internal item buffer of given outstanding batch.

Drops cached batch buffers.

Provides usage statistics.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.