Postgres lease acquisition and renewal for workflow runs.
The lease token is the fencing token used by the Postgres journal. Acquiring
a lease performs the roadmap's UPDATE ... RETURNING CAS: only unowned or
expired running runs can be claimed, and every successful claim receives a
fresh monotonic token from continuum_lease_token_seq.
Summary
Functions
Acquire a lease for a running or suspended run.
Acquire a lease or raise.
Build the owner string used in lease rows.
Renew a lease by owner and token.
Types
Functions
Acquire a lease for a running or suspended run.
Returns {:error, :not_acquired} when another owner still holds the lease.
Acquire a lease or raise.
@spec owner() :: binary()
Build the owner string used in lease rows.
@spec renew(binary(), binary(), integer(), keyword()) :: :ok | {:ok, :cancel_requested} | {:error, :lost} | {:error, term()}
Renew a lease by owner and token.
Returns {:error, :lost} when the row is gone or the owner/token no longer
match, which means another process acquired the fencing token. Returns
{:ok, :cancel_requested} when the renewal succeeded but a durable cancel
request is pending on the run (set by Continuum.cancel/2 when the owning
engine was unreachable).