Bedrock.DataPlane.Materializer.Olivine.IntakeQueue (bedrock v0.5.3)

View Source

Transaction intake queue for batching and processing encoded transactions.

Manages a queue of {encoded_transaction, version, size} tuples with operations for adding transactions and taking batches by size limits.

Summary

Functions

Adds encoded transactions to the queue. Each transaction is stored with its version and byte size.

Returns true if the queue is empty.

Creates a new empty intake queue.

Returns the number of transactions in the queue.

Takes a batch of transactions up to the specified count limit.

Takes a batch of transactions up to the specified size limit. Always takes at least one transaction, even if it exceeds the size limit.

Types

t()

@type t() :: %Bedrock.DataPlane.Materializer.Olivine.IntakeQueue{
  queue: :queue.queue({binary(), Bedrock.version(), pos_integer()})
}

Functions

add_transactions(intake_queue, encoded_transactions)

@spec add_transactions(t(), [binary()]) :: t()

Adds encoded transactions to the queue. Each transaction is stored with its version and byte size.

empty?(intake_queue)

@spec empty?(t()) :: boolean()

Returns true if the queue is empty.

new()

@spec new() :: t()

Creates a new empty intake queue.

size(intake_queue)

@spec size(t()) :: non_neg_integer()

Returns the number of transactions in the queue.

take_batch_by_count(intake_queue, max_count)

@spec take_batch_by_count(t(), pos_integer()) ::
  {[binary()], Bedrock.version() | nil, t()}

Takes a batch of transactions up to the specified count limit.

Returns {batch, last_version, updated_intake_queue}.

take_batch_by_size(intake_queue, max_size_bytes)

@spec take_batch_by_size(t(), pos_integer()) ::
  {[binary()], Bedrock.version() | nil, t()}

Takes a batch of transactions up to the specified size limit. Always takes at least one transaction, even if it exceeds the size limit.

Returns {batch, last_version, updated_intake_queue}.