chronon_core/lib.rs
1//! Chronon core — portable types and the [`SchedulerStore`] persistence port.
2//!
3//! This crate defines domain models, error types, script identity ports, and the async storage
4//! trait that backends implement. It has no runtime, scheduler, or HTTP dependencies.
5//!
6//! # Goals
7//!
8//! - Stable DTOs ([`Job`], [`Run`], [`Script`]) shared by scheduler, executor, and adapters
9//! - A single [`SchedulerStore`] port for jobs, runs, leases, and coordinator metadata
10//! - Host-injectable script identity via [`ScriptContext`] and [`ContextFactory`]
11//!
12//! # Non-goals
13//!
14//! - Running tick loops or executing scripts (see `chronon-runtime` and `chronon-executor`)
15//! - Choosing a storage backend (hosts register implementations at boot)
16//!
17//! # Modules
18//!
19//! - [`store`] — [`SchedulerStore`] trait and persistence contract
20//! - [`models`] — jobs, runs, revisions, workers, schedule enums
21//! - [`context`] — [`ScriptContext`] and [`ContextFactory`] for script dispatch
22//! - [`router`] — named store registration via [`StoreRouter`]
23//! - [`error`] — [`ChrononError`] and [`Result`]
24//!
25//! # Getting started
26//!
27//! Implement [`SchedulerStore`] for your storage substrate, then register it on
28//! [`StoreRouter::register_global`] or pass the store directly to `ChrononBuilder` in `chronon-runtime`.
29//!
30//! See also: [`DEFAULT_STORE_NAME`], [`ScriptHandle`].
31
32pub mod context;
33pub mod error;
34pub mod handle;
35pub mod models;
36pub mod router;
37pub mod store;
38
39#[cfg(test)]
40mod unit_tests;
41
42pub use context::{
43 ContextFactory, IdentityError, JsonScriptContextFactory, NoOpContextFactory, NoOpScriptContext,
44 ScriptContext,
45};
46pub use handle::ScriptHandle;
47pub use error::{ChrononError, Result};
48pub use models::{
49 Job, JobRevision, Lease, MisfirePolicy, PartitionAssignment, RetryPolicy, Run, RunStatus,
50 ScheduleKind, SchedulerLeader, Script, Worker, WorkerStatus,
51};
52pub use router::{default_store_from_global, StoreRouter, DEFAULT_STORE_NAME};
53pub use store::SchedulerStore;