Skip to main content

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 actor_policy;
33pub mod context;
34pub mod error;
35pub mod handle;
36pub mod models;
37pub mod redact;
38pub mod router;
39pub mod sanitize;
40pub mod store;
41
42#[cfg(test)]
43mod unit_tests;
44
45pub use actor_policy::{
46    default_http_enqueue_actor, is_system_shaped_actor, ActorJsonPolicy, EnqueueTrust,
47    RejectExternalSystemActor,
48};
49pub use context::{
50    ContextFactory, IdentityError, JsonScriptContextFactory, NoOpContextFactory, NoOpScriptContext,
51    ScriptContext,
52};
53pub use error::{ChrononError, Result};
54pub use handle::ScriptHandle;
55pub use models::{
56    Job, JobRevision, Lease, MisfirePolicy, PartitionAssignment, RetryPolicy, Run, RunStatus,
57    ScheduleKind, SchedulerLeader, Script, Worker, WorkerStatus, MAX_JOB_CONCURRENCY,
58    MAX_LIST_LIMIT, MAX_RETRY_ATTEMPTS, MAX_RETRY_DELAY_MS, MAX_TIMEOUT_MS,
59};
60pub use redact::{redact_credentials_in_text, redact_endpoint};
61pub use router::{default_store_from_global, StoreRouter, DEFAULT_STORE_NAME};
62pub use sanitize::{sanitize_error_message, MAX_ERROR_MESSAGE_CHARS};
63pub use store::SchedulerStore;