Skip to main content

Crate fireweed_dsl_postgres

Crate fireweed_dsl_postgres 

Source
Expand description

PostgreSQL executor for Fireweed’s data-plane DSL (API-008).

PgExecutor implements fireweed_dsl::Executor over a pool of connections, so a consumer can hold it as a dyn Executor. apply_schema creates a space’s tables and indexes from its schema, execute runs a program as one transaction of plain SQL statements over those tables, and sweep writes back time-driven state and deletes what retention has expired.

The same operations are free functions over one connection, for a caller that keeps its own. They keep nothing in the process between calls: each call reads the space’s schema from the database, checks the program against it, and runs it. Queries are sent unprepared with text parameters (query_typed), so each costs one round trip.

Structs§

PgExecutor
The PostgreSQL executor as a fireweed_dsl::Executor. Each call takes an idle connection, or opens one, and gives it back when the call finishes. A call that is dropped part way drops its connection instead, so no connection with an open transaction is reused. Connections are opened on demand; at most max_idle are kept between calls.

Functions§

apply_schema
Creates a space, or changes its schema (API-008 §Changing a schema). expected is the version the caller expects to replace: None for a new space.
execute
Runs a program as one transaction (API-008 §Transactions).
execute_batch
Runs independent programs in one space as one transaction with one commit (API-008 §Batches). Each program runs under its own savepoint, so one that fails or rejects leaves the others alone; each gets its own result, in order. A program that hits a deadlock is run again.
get_schema
The stored schema of a space, if it exists.
sweep
Writes back time-driven state and deletes what retention has expired, at most batch rows per object (API-008 §Time). Rows other transactions hold are skipped.