BaileysEx.Message.OfflineQueue (baileys_ex v0.1.0-alpha.9)

Copy Markdown View Source

FIFO offline node batching owned by the caller's process state.

This mirrors Baileys' offline queue semantics without introducing a separate process: the owner keeps the queue in its state, drains up to 10 nodes per pass, and lets the caller reschedule the next drain when work remains.

Summary

Functions

Drains up to the configured batch size of nodes from the queue.

Pushes a new node onto the offline processing queue.

Initializes a new offline queue.

Types

drain_result()

@type drain_result() :: %{processed_count: non_neg_integer(), continue?: boolean()}

node_type()

@type node_type() :: :message | :call | :receipt | :notification

t()

@type t() :: %BaileysEx.Message.OfflineQueue{
  batch_size: pos_integer(),
  buffering?: boolean(),
  queue: term()
}

Functions

drain(state, context, processor)

@spec drain(t(), map(), (node_type(), BaileysEx.BinaryNode.t() ->
                     :ok | {:error, term()})) ::
  {:ok, t(), drain_result()} | {:error, term(), t()}

Drains up to the configured batch size of nodes from the queue.

enqueue(state, type, node)

@spec enqueue(t(), node_type(), BaileysEx.BinaryNode.t()) :: t()

Pushes a new node onto the offline processing queue.

new(opts \\ [])

@spec new(keyword()) :: t()

Initializes a new offline queue.