Skip to main content

Crate chronon

Crate chronon 

Source
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 ….

ExampleShowsFeatures
script_macro#[chronon::script] + Job::new + upsert_job + tickmem
script_handle_jobMacro ScriptHandle → default job + typed paramsmem
run_nowManual job + CoordinatorService::run_nowmem
embedded_tickDue job enqueue via tick_oncemem
store_router_bootGlobal StoreRouter installmem
sqlite_bootSQLite store bootsqlite
postgres_boot / postgres_redis_bootDurable backendspostgres / postgres,redis
axum_hostMount HTTP routermem,axum
coordinator_daemon / worker_daemonSplit deployment shapespostgres,redis

§Documentation map

Full snippets live on the linked items (not repeated here).

§Configuration

Settings merge in this order: explicit ChrononBuilder values override environment defaults where both exist.

SettingBuilder APIEnvironmentDefault
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_MS250 ms
Instance id.instance_id()random UUID
Partition count— (env only)CHRONON_NUM_PARTITIONS64

§Backend connection (pass to store constructors, not ChrononBuilder)

BackendConfiguration
PostgreSQLURL to PostgresSchedulerStore::connect; CHRONON_POSTGRES_URL / CHRONON_TEST_POSTGRES_URL for tests
SQLitePath or URL to SqliteSchedulerStore
Redis overlayURL 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:

FeatureTypeStatus
memInMemorySchedulerStoreReady — tests and local dev
sqliteSqliteSchedulerStoreReady — embedded file-backed
postgresPostgresSchedulerStoreReady — shared durable
redisPostgresRedisSchedulerStoreReady — Postgres + Redis claim overlay (requires postgres feature)
axumchronon_router, HTTP DTOsReady — mount on host Axum server
telemetry-consoleDocuments ConsoleSink usageOptional 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.
ChrononBuilder
Builds a crate::Chronon runtime with explicit adapter injection.
ConsoleSink
Writes telemetry to stderr (development and bench).
CoordinatorService
Object-safe coordinator operations backed by SchedulerStore.
CronExpr
A parsed cron expression ready for next-run calculations.
NoOpSink
Discards all telemetry (default for tests and minimal hosts).
ScriptDescriptor
Descriptor for a registered script.
ScriptHandle
A typed handle for scheduling a script with specific parameters.
ScriptRegistry
In-memory script registry with optional link-time inventory discovery.

Enums§

ChrononError
Errors that can occur in Chronon operations.
DeploymentShape
Named deployment assembly — not a global mode enum.

Traits§

TelemetrySink
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.