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
SqlSchedulerStore— connect, schema bootstrap, and trait implementationSqlDialect/SqlPool— engine selection and pool wrapperbind_sql— dialect-specific placeholder rewriting (?→$1, …)validate_postgres_schema_name— allowlist for isolated schema DDL /search_path
§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
SchedulerStoremethod 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§
- Scheduler
Leader Row - SQL row shape for
SchedulerLeader. - SqlScheduler
Store - SQL-backed
SchedulerStore(PostgreSQLorSQLite).
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 SQLiteuses?placeholders;PostgreSQLuses$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.