Context for managing outbound adapter sequence budgets.
Summary
Functions
Gets a budget by adapter and sequence version.
Gets an existing budget or creates the default lazy budget.
Lists budgets for optional adapter and sequence-version filters.
Creates or updates a per-adapter, per-sequence budget.
Functions
@spec get_budget(Ecto.UUID.t(), Ecto.UUID.t()) :: Ecto.Schema.t() | nil
Gets a budget by adapter and sequence version.
@spec get_or_create_budget(Ecto.UUID.t(), Ecto.UUID.t()) :: {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t() | :budget_unavailable}
Gets an existing budget or creates the default lazy budget.
Race-safe: concurrent callers go through an upsert with on_conflict: :nothing
on the (adapter_id, sequence_version_id) unique index, then re-fetch.
@spec list_budgets(map()) :: [Ecto.Schema.t()]
Lists budgets for optional adapter and sequence-version filters.
@spec set_adapter_sequence_budget(Ecto.UUID.t(), Ecto.UUID.t(), map()) :: {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
Creates or updates a per-adapter, per-sequence budget.
The budget's tenant_key is inherited from the adapter so tenant scope is
enforced at the row level even though the unique key is (adapter_id, sequence_version_id).