Fireweed
Fireweed is the data plane for Snorri and Cayce: queues and tables for short-lived, scale-out workflow data, changed through a small typed DSL and run as plain SQL.
A consumer describes its data in a schema document: queues, tables,
typed fields, indexes and named reads. It changes that data with
programs: lists of typed statements (insert, claim, settle,
renew, update, delete, assert, select, read, pause,
resume) that run as one transaction. Both are YAML or JSON.
An executor creates real tables and indexes from the schema and runs each statement as one SQL statement over them. The database chooses rows by index, orders writers with row locks and decides with its clock when work is due. The executor keeps nothing in the process between calls.
- ADR-027: the decision and the owner's rulings.
- API-008: the DSL reference and the PostgreSQL executor's rules.
Crates
| Crate | What it is |
|---|---|
fireweed-dsl |
Schema and program documents, the checker that resolves a program against a schema, and the Executor trait every backend implements. |
fireweed-dsl-postgres |
The PostgreSQL 18 executor: PgExecutor implements Executor over a pool of connections; the same operations are functions over one connection. |
fireweed-umf |
Space schemas as UMF core 0.10 documents with the fireweed.space extension (API-009). |
fireweed-dsl-local |
The Turso executor: one database per space on local disk, with the log optionally shipped to S3 (feature s3); Local implements Executor. |
All four are on crates.io:
[]
= "0.37"
= "0.37"
= "0.37" # only for UMF schema documents
= "0.37" # only for the in-process Turso executor
Application code depends on fireweed-dsl alone and takes an
Arc<dyn fireweed_dsl::Executor>; only the binary that starts it names a
backend:
use Arc;
use Executor;
let exec: = match backend ;
Releases are cut by pushing a tag vX.Y.Z from main; see
CHANGELOG.md and .github/workflows/release.yml.
Example
A schema:
version: 1
queues:
work:
max_attempts: 5
fields:
campaign:
A program that enqueues two items, and one that claims them:
request_id: enqueue-1
issued_at:
statements:
- insert:
request_id: claim-1
issued_at:
statements:
- claim:
The claim returns each item's id and lease token. A later program
settles them:
request_id: settle-1
issued_at:
statements:
- settle:
From Rust:
use Executor;
let engine = new;
let schema: Schema = from_yaml?;
engine.apply_schema.await?;
let program: Program = from_yaml?;
let response = engine.execute.await?;
Development
Prerequisites: rustup (the repository selects Rust
1.99.0) and PostgreSQL 18. docker compose up -d postgres starts one on
port 55432.
FIREWEED_PG_TEST_URL=postgres://fireweed:fireweed@127.0.0.1:55432/fireweed
Without FIREWEED_PG_TEST_URL the executor's tests skip.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option. Contributions are issues only; see CONTRIBUTING.md.