DSL reference

A summary of the schema and program documents. The full specification, with every rule and the SQL each statement becomes, is API-008. For the Rust functions, see Rust crates.

Both documents are YAML or JSON; unknown keys are refused. Object, field, parameter and read names match [a-z][a-z0-9_]{0,47}. Durations are a string with a unit (250ms, 30s, 5m, 2h, 7d) or milliseconds.

Schema document

KeyMeaning
versionIncreases with every change. apply_schema takes the version it expects to replace.
request_retentionHow long request ids are remembered. Default 1d.
queues.<name>max_attempts (default 10, or unlimited), retention of finished items (default 7d), priority (asc or desc), fields.
tables.<name>key (fields that identify a row), or sequenced: true; expire_after_write; fields.
fields.<name>type; index: true; merge (add_only or non_decreasing).
readsNamed, versioned selects with typed params. A name and version, once declared, never change.

Program document

KeyMeaning
request_idRequired if any statement writes. A replay returns the recorded response.
issued_atRequired with request_id: when the caller created it. Resent unchanged on every retry.
durabilitydurable (default) or fire_and_forget.
paramsValues the statements refer to as {param: name}.
statementsRun in order, as one transaction. The response has one result per statement.

Statements

StatementDoesResult
insertAdds queue items or table rows. on_conflict: skip (default), reject, or update on tables.[{id, key?, status}]
claimLeases up to limit due items for lease, in claim order, skipping rows other transactions hold.Items with token
settleEnds leases as complete, fail, retry or release, with set and body patches.[{id, status: ok | stale}]
renewExtends unexpired leases.As settle
updateChanges matched rows. expect bounds the match count; on_limit: step pages large changes; leased picks how leased items are treated.{matched, met?, more?, last?}
deleteDeletes matched rows.{matched, met?}
assertCounts matched rows against expect; writes nothing.{matched, met}
selectReads fields, or an aggregate with group_by; order_by; limit required.Row objects
readRuns a declared read with its parameters.Row objects
pause, resumeA paused queue's claims return nothing.{}

Inside a statement

  • Operands: a column, {field: name}, {param: name}, {value: v}, {now: "-5m"}, {path: /a/b, type: text} into a queue item's body. No implicit casts.
  • Predicates: and, or, not; eq, ne, lt, le, gt, ge; in; contains; is_null, not_null; exists, a lookup in another object of the space.
  • Assignments: a value or operand, add, sub, coalesce, set_add, set_remove.
  • Body patches: set, remove, append with keep_last, replace.

Rejections and errors

A rejection rolls back every statement, keeps the request record and reports the statement and reason: key_conflict, stale_lease, limit_exceeded, expect_unmet, merge_violation. Errors change nothing and are not recorded: invalid, space_not_found, schema_conflict, request_id_conflict, request_expired, contention, unavailable.

Limits

LimitValue
Statements per program64
Rows per insert; items per settle or renew1,000
claim limit1,000
update, delete and select limit10,000
Program size8 MiB
Programs per execute_batch64
Statement timeout5 s