Electric.Shapes.Consumer.Subqueries.MoveQueue (electric v1.6.2)

Copy Markdown View Source

Multi-dependency move queue. Tracks move_in/move_out operations per dependency index, with deduplication and redundancy elimination scoped per dependency.

Move-outs from any dependency are drained before move-ins from any dependency.

Summary

Functions

Enqueue a materializer payload for a specific dependency. dep_view is the current view for this dependency, used for redundancy elimination.

Pop the next batch of operations. Returns move-out batches (any dep) before move-in batches. Returns {batch, updated_queue} or nil if the queue is empty.

Types

batch()

@type batch() :: {batch_kind(), non_neg_integer(), [move_value()]}

batch_kind()

@type batch_kind() :: :move_out | :move_in

move_value()

@type move_value() :: {term(), term()}

t()

@type t() :: %Electric.Shapes.Consumer.Subqueries.MoveQueue{
  move_in: %{required(non_neg_integer()) => [move_value()]},
  move_out: %{required(non_neg_integer()) => [move_value()]}
}

Functions

enqueue(queue, dep_index, payload, dep_view)

@spec enqueue(t(), non_neg_integer(), map() | keyword(), MapSet.t()) :: t()

Enqueue a materializer payload for a specific dependency. dep_view is the current view for this dependency, used for redundancy elimination.

length(move_queue)

@spec length(t()) :: non_neg_integer()

new()

@spec new() :: t()

pop_next(queue)

@spec pop_next(t()) :: {batch(), t()} | nil

Pop the next batch of operations. Returns move-out batches (any dep) before move-in batches. Returns {batch, updated_queue} or nil if the queue is empty.