Rust crates
fireweed-dsl reads and checks documents.
fireweed-dsl-postgres runs them. Generate the full docs with
cargo doc -p fireweed-dsl -p fireweed-dsl-postgres --no-deps --open.
The Executor trait
Every backend implements fireweed_dsl::Executor, so
application code holds an Arc<dyn Executor> and
names no backend. Each method returns a boxed Send
future of fireweed_dsl::Result, and calls may run
concurrently. fireweed_dsl_postgres::PgExecutor::new(config)
runs over a pool of PostgreSQL connections;
fireweed_dsl_local::Local runs on Turso with its log in
S3. Neither holds rows or schemas between calls: each reads the
space's schema, checks the program against it, and runs it.
| Method | Does |
|---|---|
apply_schema(tenant, space, &Schema, expected: Option<i64>) -> Applied | Creates a space, or applies an additive change. expected is the version being replaced, None for a new space. An identical schema is accepted unchanged. |
get_schema(tenant, space) -> Option<Schema> | The stored schema of a space. |
execute(tenant, space, &Program) -> Response | Runs a program as one transaction. On PostgreSQL, retries a deadlock up to 5 times, then fails with Contention. |
execute_batch(tenant, space, &[Program]) -> Vec<Result<Response>> | Runs up to 64 independent programs in one transaction with one commit, each under its own savepoint. Results come back in order. |
sweep(tenant, space, batch: u32) -> Swept | Writes back lapsed leases and deletes what retention has expired, at most batch rows per object. |
fireweed_dsl_postgres also offers the same five
operations as functions over one tokio_postgres::Client,
for a caller that keeps its own connection.
Types in fireweed_dsl
| Item | What it is |
|---|---|
from_yaml<T>(&str) | Reads a YAML or JSON document into a Schema or Program. |
Schema, Program, Statement | The documents, with serde names matching the YAML keys. |
Response | request_id, status (Committed or Rejected), rejected, results, durability, replayed. |
Applied | version and whether the schema changed. |
Error | Invalid, SpaceNotFound, SchemaConflict, RequestIdConflict, RequestExpired, Contention, NotOwner, RetryLater, Unavailable. Non-exhaustive. is_retryable() says whether sending the same program again may succeed. |
check::resolve(&Schema, &Program) | Checks a program against a schema without a database. |
Swept reports
expired_leases and deleted. For a working
program, see get started.