pub struct Chronon {
pub store: Arc<dyn SchedulerStore>,
pub scheduler: Arc<Scheduler>,
pub executor: Arc<Executor>,
pub coordinator: CoordinatorService,
pub deployment: DeploymentShape,
/* private fields */
}Expand description
Assembled Chronon runtime: store, scheduler, executor, and deployment loops.
Built via ChrononBuilder. Hosts typically:
- Upsert jobs through
Self::coordinator_service(or HTTP / remote client). - Call
Self::runto start shape-specific loops (orSelf::tick_oncein tests). - Call
Self::shutdownon exit.
DeploymentShape | Self::run behavior |
|---|---|
Embedded | Tick + worker in this process |
CoordinatorOnly | Tick + partitions only |
Worker(pool) | Claim + execute for pool |
RemoteClient(_) | Error — use crate::RemoteCoordinatorClient |
§Examples
use std::sync::Arc;
use chronon_backend_mem::InMemorySchedulerStore;
use chronon_runtime::{ChrononBuilder, DeploymentShape};
let chronon = ChrononBuilder::new()
.scheduler_store(Arc::new(InMemorySchedulerStore::new()))
.embedded()
.build()
.unwrap();
assert_eq!(chronon.deployment, DeploymentShape::Embedded);
let _ = chronon.coordinator_service();Fields§
§store: Arc<dyn SchedulerStore>Shared persistence for jobs, runs, partitions, and workers.
scheduler: Arc<Scheduler>Tick engine and partition assigner handle.
executor: Arc<Executor>Script registry and async dispatch.
coordinator: CoordinatorServiceJob/run CRUD facade over Self::store.
deployment: DeploymentShapeDeployment shape selected at build time.
Implementations§
Source§impl Chronon
impl Chronon
Sourcepub fn shutdown_handle(&self) -> Arc<Notify>
pub fn shutdown_handle(&self) -> Arc<Notify>
Shared shutdown signal for background Self::run tasks (testkit / host wiring).
Sourcepub async fn run(&mut self) -> Result<()>
pub async fn run(&mut self) -> Result<()>
Run deployment loops until Self::shutdown is called.
Dispatches on Self::deployment:
DeploymentShape::Embedded— tick + workerDeploymentShape::CoordinatorOnly— tick onlyDeploymentShape::Worker— claim + executeDeploymentShape::RemoteClient— returnsChrononError::Internal; usecrate::RemoteCoordinatorClientinstead
Call scheduler.init_partitions().await before Self::run on coordinator /
embedded shapes so partition ownership is ready.
§Examples
Embedded: init partitions, then run until shutdown:
use std::sync::Arc;
use chronon_backend_mem::InMemorySchedulerStore;
use chronon_runtime::ChrononBuilder;
let mut chronon = ChrononBuilder::new()
.scheduler_store(Arc::new(InMemorySchedulerStore::new()))
.embedded()
.build()?;
chronon.scheduler.init_partitions().await;
// chronon.run().await?; // blocks until chronon.shutdown()Runnable daemons: cargo run -p uf-chronon --example coordinator_daemon --features postgres,redis
and worker_daemon.
Sourcepub async fn tick_once(&self) -> Result<TickResult>
pub async fn tick_once(&self) -> Result<TickResult>
Advance the scheduler by one tick (tests and manual stepping).
Sourcepub fn coordinator_service(&self) -> &CoordinatorService
pub fn coordinator_service(&self) -> &CoordinatorService
Job and run CRUD for HTTP handlers and host integration.