Portable control plane for pause, update, resume and terminal stop.
Summary
Functions
Increments the fencing generation, invalidating attempts fenced on the previous value.
Returns true when a command id is pending, last applied, or in history —
the idempotency check behind {:duplicate, control} replies.
Records a command as finished, clearing the pending slot.
Creates the control plane for one loop, starting in :active state.
Commits a control command as the single pending command.
Returns true when the control plane has reached its terminal state.
Forces the control plane terminal, rejecting any still-pending command.
Validates the whole control plane: scalar fields, embedded commands, history identity and state/pending consistency.
Types
@type t() :: %Spectre.Operation.Control{ desired_state: :active | :paused | :terminal, generation: non_neg_integer(), history: [Spectre.Operation.Control.Command.t()], last_command: Spectre.Operation.Control.Command.t() | nil, loop_id: String.t(), pause_mode: :safe | :immediate, pending: Spectre.Operation.Control.Command.t() | nil, state: :active | :pause_requested | :paused | :stopping | :terminal, updated_at: non_neg_integer() | nil }
Functions
Increments the fencing generation, invalidating attempts fenced on the previous value.
Returns true when a command id is pending, last applied, or in history —
the idempotency check behind {:duplicate, control} replies.
@spec finish(t(), Spectre.Operation.Control.Command.t()) :: t()
Records a command as finished, clearing the pending slot.
The finished command becomes last_command and the head of the bounded
history; the control state follows the command's desired_state.
Creates the control plane for one loop, starting in :active state.
@spec request(t(), Spectre.Operation.Control.Command.t()) :: {:ok, t()} | {:duplicate, t()} | {:error, term()}
Commits a control command as the single pending command.
Replays of an already seen command id return {:duplicate, control};
a terminal control plane, a target mismatch or an already pending command
return {:error, reason}. Pause-like commands move the state to
:pause_requested.
Returns true when the control plane has reached its terminal state.
Forces the control plane terminal, rejecting any still-pending command.
A loop can reach a terminal outcome while a safe pause or update command is still pending; the command can no longer be applied, so it is finished as rejected before the terminal state is committed.
Validates the whole control plane: scalar fields, embedded commands, history identity and state/pending consistency.
Returns :ok or {:error, reason} naming the first violated invariant.