Durable FSM engine on top of Postgres + GenServer.
Start the engine in a host supervision tree:
{GenDurable,
repo: MyApp.Repo,
fsms: [Checkout],
queues: [default: 10, checkout: 5]}Then enqueue instances and deliver signals:
{:ok, id} = GenDurable.insert(Checkout, state: %{order: 42}, partition_key: "order:42")
:ok = GenDurable.signal(id, "payment_confirmed", %{amount: 100}, dedup_key: "evt-7")See gen_durable_spec.md (normative) and gen_durable_plan.md (roadmap).
Summary
Functions
Enqueue one FSM instance. Options: :state, :step (default the FSM's
:initial), :queue, :priority, :partition_key, :unique_key,
:unique_scope, :eligible_at. Returns {:ok, id} or {:error, :duplicate}.
Batch-enqueue instances in a single statement (dedup via the partial unique
index). entries is a list of per-instance option keyword lists. Returns the
list of inserted ids (duplicates dropped).
Deliver a durable signal to an instance (spec §5). Wakes the instance only on
a name match. :dedup_key (default nil) makes redelivery idempotent.
Functions
Enqueue one FSM instance. Options: :state, :step (default the FSM's
:initial), :queue, :priority, :partition_key, :unique_key,
:unique_scope, :eligible_at. Returns {:ok, id} or {:error, :duplicate}.
Batch-enqueue instances in a single statement (dedup via the partial unique
index). entries is a list of per-instance option keyword lists. Returns the
list of inserted ids (duplicates dropped).
Deliver a durable signal to an instance (spec §5). Wakes the instance only on
a name match. :dedup_key (default nil) makes redelivery idempotent.