Skip to main content

Module queued_work

Module queued_work 

Source
Expand description

Dialect-independent queued-work claim logic shared by durable backends.

The SQL backends (sqlite, postgres) load candidate batch rows ordered by enqueue_seq and pre-filtered to ready batches that are not held by a live claim, then apply the same pure state machine: a delivery-policy boundary gate, slot-policy/merge-key prefix grouping, and fencing-token / lease derivation. That state machine lives here so the backends own only their SQL reads and writes while the claim contract has a single implementation, exercised against every backend by the shared runtime_persistence conformance suite.

Structs§

ClaimCandidate
Decoded claim-relevant fields of one ready queued-work batch row.
QueuedWorkClaimLease
A freshly derived lease for a selected claim prefix.

Functions§

claim_scan_limit
How many candidate rows a backend should scan when selecting up to max_batches claimable batches. Joinable groups are matched as a prefix, so scanning a bounded surplus keeps one round trip sufficient.
derive_batch_id
Derive the durable id for a newly enqueued batch.
ensure_completion_owns_all_batches
Apply the shared completion-fencing decision: a completion may delete its batches only when the live store still shows the claim owning every one of them (owned_rows rows matched the claim id + lease token).
renewed_claim
Apply the shared lease-renewal decision: the lease holds only when every batch row in the claim accepted the new expiry stamp.
select_claim_prefix
Select the prefix of candidates that a single claim may take.