Expand description
Local disk-persisted queue backed by turso (localqueue.v1), multi-process safe.
§Connection strategy
turso is async-native and its Connection is Send + Sync, so there is no
spawn_blocking boundary and no Mutex<Connection> anywhere. LocalQueue
holds one turso::Database handle on <dataDir>/localqueue.sqlite; each
operation opens its own short-lived connection from it and drops it
when the operation completes, so no statement state leaks between
operations.
Correctness under concurrent access (multiple handles on one file, i.e.
multiple processes) comes from turso’s multi-process WAL mode — enabled
explicitly, experimental upstream, and gated by the multi-handle tests
below — plus a busy_timeout (writers wait for the write lock instead of
failing with Busy).
§Receive design: one BEGIN IMMEDIATE transaction per batch
The pinned localqueue.v1 receive is one atomic
UPDATE ... SET receipt_handle = ?uuid ... RETURNING .... A single bound
parameter cannot mint a distinct UUID per claimed row, so this
implementation uses the sanctioned equivalent: one BEGIN IMMEDIATE
transaction per batch that selects the due ids, then runs that exact
per-row UPDATE ... RETURNING with a fresh UUID for each, and commits.
IMMEDIATE takes the write lock at BEGIN, so concurrent receivers (in
any process) serialize on the whole claim: a message is delivered to
exactly one receiver per visibility window.
See crates/alien-bindings/FORMAT.md for the on-disk localqueue.v1
contract, including the "{id}:{uuid}" caller-facing receipt-handle format.
Structs§
- Local
Queue - Local disk-persisted queue on turso (
localqueue.v1).