Struct multistream_batch::multi_buf_batch::MultiBufBatch [−][src]
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 keyK
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.
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.