Skip to main content

Module coordination

Module coordination 

Source
Expand description

Versioned key-value objects for coordinating writers that share one store.

A CoordinationStore keeps small values (JSON documents, markers) under slash-separated keys, each with a version number that changes on every write. The only ways to write are create if absent and compare and swap, which map onto what every backend can do atomically: a local transaction (SQLite), an OS lock (a directory), or a conditional PUT (If-None-Match: * / If-Match on S3 and R2, x-goog-if-generation-match on GCS).

It is what a gateway uses for idempotency markers (webhook deliveries, cron fires: create-if-absent), leases and fencing (compare-and-swap), and anything else that must be decided exactly once across restarts.

Keys are namespaced per deployment with deployment_key, e.g. d/<deployment>/runs/<run_id>.

Structs§

Versioned
A stored value and its version. Versions start at 1 and increase by one per write of the key.

Constants§

MAX_KEY_BYTES
Largest key, in bytes.
MAX_VALUE_BYTES
Largest value, in bytes. Coordination objects stay well below the single-PUT limits of object stores (5 MiB), so no backend needs multipart uploads.

Traits§

CoordinationStore
Versioned objects written only with create-if-absent and compare-and-swap.

Functions§

deployment_key
The key of object id of kind in deployment: d/<deployment>/<kind>/<id>.
validate_key
Validate a coordination key: 1–MAX_KEY_BYTES bytes of /-separated segments of [A-Za-z0-9_.:=-], none empty, . or ...
validate_value
Validate a value size.