Skip to main content

Crate chronon_backend_sql_common

Crate chronon_backend_sql_common 

Source
Expand description

Shared SQL SchedulerStore for PostgreSQL and SQLite.

Backend and platform engineers use this crate when implementing or extending SQL persistence. Application binaries should prefer the thin wrappers chronon_backend_postgres or chronon_backend_sqlite.

§Stack position

chronon-backend-{postgres,sqlite} → chronon-backend-sql-common → chronon-core

§Entry points

§Prerequisites

Schema bootstrap runs on connect. For parallel Postgres tests use SqlSchedulerStore::connect_postgres_isolated (schema names must match validate_postgres_schema_name).

§Example

use chronon_backend_sql_common::SqlSchedulerStore;

let store = SqlSchedulerStore::connect_sqlite("sqlite://:memory:").await?;

Macros§

delegate_scheduler_store
Delegate every SchedulerStore method to $field.
sql_execute
Execute a parameterized SQL statement on the store pool.
sql_fetch_all_map
Fetch all rows and map each through a closure.
sql_fetch_one_map
Fetch exactly one row and map it through a closure.
sql_fetch_optional_map
Fetch zero or one row and map it through a closure.

Structs§

SchedulerLeaderRow
SQL row shape for SchedulerLeader.
SqlSchedulerStore
SQL-backed SchedulerStore (PostgreSQL or SQLite).

Enums§

SqlDialect
SQL dialect for query variants.
SqlPool
Connection pool for a SQL backend.

Constants§

LEADER_ROW_ID
Fixed primary key for the singleton leader election row.

Functions§

bind_sql
SQLite uses ? placeholders; PostgreSQL uses $1, $2, …
row_to_worker
Map a SQL row to a Worker.
run_pool_key
Resolve the Redis / queue pool key for a run ("general" when unset).
validate_postgres_schema_name
Validate a Postgres schema name before interpolating it into DDL / search_path.