Schema
Queues, tables and sequenced tables with typed fields, indexes, merge rules, retention and named, versioned reads. Each object becomes a real table. Changes only add.
Declare a space's queues, tables and reads in a schema document. Change them with programs: lists of typed statements, such as claim, settle, update and select, that run in order as one transaction. The PostgreSQL executor turns each statement into one SQL statement and keeps nothing in the process between calls.
Queues, tables and sequenced tables with typed fields, indexes, merge rules, retention and named, versioned reads. Each object becomes a real table. Changes only add.
insert, claim, settle,
renew, update, delete,
assert, select, read,
pause and resume. Predicates and
assignments are typed data, never SQL text.
A program is checked against the schema: names resolve, types match with no implicit casts, and every selection uses an index. Then each statement becomes one SQL statement with bound parameters.
A where must test an indexed column. A claim reads the
(due_at, priority, id) claim index, so it reads about
limit entries however many items are sleeping.
Claims skip rows other transactions hold. Guards lock the rows they count, so a counted row can't change before the program commits.
Due items, lapsed leases and retention are conditions on stored times, read against the database's clock. No caller drives a tick.
PostgreSQL 18 is the first and currently only executor. The crates
fireweed-dsl and fireweed-dsl-postgres are on
crates.io. See support.
Insert three sends, lease the due ones in claim order, then complete one and retry the other in the same program.
Create a keyed row once, advance it with compare-and-set on its version, and enqueue a send only when a guard finds no suppression row.
Count a queue by state and by campaign with no where clause, and run the same count for one campaign through a declared read.