Expand description
Chronon — cron and run-once scheduling for Rust services.
Chronon provides typed script handlers, durable job/run history, and optional
coordinator–worker split behind a thin SchedulerStore port.
Feature-gated backends and HTTP adapters sit behind the public facade.
§Getting started
Cargo examples are not auto-indexed by rustdoc. Use the table below (also in
chronon/README.md),
or cargo run -p uf-chronon --example <name> --features ….
| Example | Shows | Features |
|---|---|---|
script_macro | #[chronon::script] + Job::new + upsert_job + tick | mem |
script_handle_job | Macro ScriptHandle → default job + typed params | mem |
run_now | Manual job + CoordinatorService::run_now | mem |
embedded_tick | Due job enqueue via tick_once | mem |
store_router_boot | Global StoreRouter install | mem |
sqlite_boot | SQLite store boot | sqlite |
postgres_boot / postgres_redis_boot | Durable backends | postgres / postgres,redis |
axum_host | Mount HTTP router | mem,axum |
coordinator_daemon / worker_daemon | Split deployment shapes | postgres,redis |
§Documentation map
Full snippets live on the linked items (not repeated here).
- Boot the runtime —
ChrononBuilder,DeploymentShape,Chronon::run - Define scripts —
scriptattribute,ScriptContext,ContextFactory - Schedule a job —
Job,CoordinatorService::upsert_job, typed defaults viaScriptHandle - Run immediately —
CoordinatorService::run_now(manual / on-demand) - Persist jobs and runs —
SchedulerStore,Run - Manage jobs programmatically —
CoordinatorService - Parse cron —
CronExpr - Register storage —
install_default_mem_store(memfeature),StoreRouter - HTTP API —
chronon_router(axumfeature) - Metrics —
TelemetrySink
§Configuration
Settings merge in this order: explicit ChrononBuilder values override environment
defaults where both exist.
| Setting | Builder API | Environment | Default |
|---|---|---|---|
| Store | .scheduler_store() / .scheduler_store_from_global() | — | required |
| Context factory | .context_factory() | — | NoOpContextFactory |
| Telemetry | .telemetry_sink() | — | NoOpSink |
| Script registry | .script_registry() / .auto_registry() | — | empty or inventory |
| Tick interval | .tick_interval_ms() | CHRONON_TICK_INTERVAL_MS | 250 ms |
| Instance id | .instance_id() | — | random UUID |
| Partition count | — (env only) | CHRONON_NUM_PARTITIONS | 64 |
§Backend connection (pass to store constructors, not ChrononBuilder)
| Backend | Configuration |
|---|---|
| PostgreSQL | URL to PostgresSchedulerStore::connect; CHRONON_POSTGRES_URL / CHRONON_TEST_POSTGRES_URL for tests |
| SQLite | Path or URL to SqliteSchedulerStore |
| Redis overlay | URL to RedisQueueLayer::connect; optional key prefix (default chronon); CHRONON_REDIS_URL in production |
Lease TTLs, tick batch limits, worker pool, and worker concurrency are environment-only.
See chronon-scheduler crate documentation for the full environment variable table.
§Cargo features
No features are enabled by default. Enable explicitly:
| Feature | Type | Status |
|---|---|---|
mem | InMemorySchedulerStore | Ready — tests and local dev |
sqlite | SqliteSchedulerStore | Ready — embedded file-backed |
postgres | PostgresSchedulerStore | Ready — shared durable |
redis | PostgresRedisSchedulerStore | Ready — Postgres + Redis claim overlay (requires postgres feature) |
axum | chronon_router, HTTP DTOs | Ready — mount on host Axum server |
telemetry-console | Documents ConsoleSink usage | Optional marker (ConsoleSink always re-exported) |
Re-exports§
pub use quark::inventory;pub use chronon_core as core;
Modules§
- prelude
- Curated re-exports for application developers building Chronon worker binaries.
Structs§
- Chronon
- Assembled Chronon runtime: store, scheduler, executor, and deployment loops.
- Chronon
Builder - Builds a
crate::Chrononruntime with explicit adapter injection. - Console
Sink - Writes telemetry to stderr (development and bench).
- Coordinator
Service - Object-safe coordinator operations backed by
SchedulerStore. - Cron
Expr - A parsed cron expression ready for next-run calculations.
- NoOp
Sink - Discards all telemetry (default for tests and minimal hosts).
- Script
Descriptor - Descriptor for a registered script.
- Script
Handle - A typed handle for scheduling a script with specific parameters.
- Script
Registry - In-memory script registry with optional link-time inventory discovery.
Enums§
- Chronon
Error - Errors that can occur in Chronon operations.
- Deployment
Shape - Named deployment assembly — not a global mode enum.
Traits§
- Telemetry
Sink - Host-injectable telemetry sink for scheduler and executor metrics/events.
Functions§
- builder
- Shorthand for
ChrononBuilder::new.
Type Aliases§
- Result
- Result type alias for Chronon operations.
Attribute Macros§
- script
- Marks an async function as a Chronon script, enabling automatic registration and typed parameter handling.