Expand description
SQLite SchedulerStore for Chronon.
When to use: durable single-host Mode 1, or same-host Mode 2 when coordinator and worker open the same database file (SQLite allows one writer at a time — prefer Postgres ± Redis for multi-worker fleets).
Getting started: Mode 1 / Mode 2.
§Stack position
chronon (facade, `sqlite` feature) → chronon-backend-sqlite → chronon-backend-sql-common → chronon-core§Entry points
SqliteSchedulerStore::new— open a database fileSqliteSchedulerStore::connect— connect via URL (including:memory:)
§Mode 1 — Embedded
ⓘ
use std::sync::Arc;
use chronon::prelude::*;
use chronon::SqliteSchedulerStore;
let store = SqliteSchedulerStore::connect("sqlite:///var/lib/chronon/chronon.db").await?;
let chronon = ChrononBuilder::new()
.scheduler_store(Arc::new(store))
.context_factory(Arc::new(JsonScriptContextFactory))
.embedded()
.auto_registry()
.build()?;Runnable: cargo run -p uf-chronon --example sqlite_boot --features sqlite
§Mode 2 — Coordinator binary
Shared file path with the worker. Tick only — no script execution in this process:
ⓘ
use std::sync::Arc;
use chronon::prelude::*;
use chronon::SqliteSchedulerStore;
let path = std::env::var("CHRONON_SQLITE_PATH")
.unwrap_or_else(|_| "/tmp/chronon-remote.db".into());
let store = SqliteSchedulerStore::new(&path).await?;
let mut chronon = ChrononBuilder::new()
.scheduler_store(Arc::new(store))
.context_factory(Arc::new(JsonScriptContextFactory))
.instance_id("coordinator-0")
.coordinator_only()
.build()?;
chronon.scheduler.init_partitions().await;
chronon.run().await?;§Mode 2 — Worker binary
Same CHRONON_SQLITE_PATH, unique CHRONON_INSTANCE_ID, scripts linked via .auto_registry():
ⓘ
use std::sync::Arc;
use chronon::prelude::*;
use chronon::SqliteSchedulerStore;
let path = std::env::var("CHRONON_SQLITE_PATH")
.unwrap_or_else(|_| "/tmp/chronon-remote.db".into());
let store = SqliteSchedulerStore::new(&path).await?;
let mut chronon = ChrononBuilder::new()
.scheduler_store(Arc::new(store))
.context_factory(Arc::new(JsonScriptContextFactory))
.instance_id(std::env::var("CHRONON_INSTANCE_ID").unwrap_or_else(|_| "worker-1".into()))
.auto_registry()
.worker("general")
.build()?;
chronon.run().await?;Other Mode 2 backends: Postgres, Postgres + Redis.
Structs§
- Sqlite
Scheduler Store - SQLite-backed scheduler store.