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<(), ChrononError>
pub async fn run(&mut self) -> Result<(), ChrononError>
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, ChrononError>
pub async fn tick_once(&self) -> Result<TickResult, ChrononError>
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.
Auto Trait Implementations§
impl !RefUnwindSafe for Chronon
impl !UnwindSafe for Chronon
impl Freeze for Chronon
impl Send for Chronon
impl Sync for Chronon
impl Unpin for Chronon
impl UnsafeUnpin for Chronon
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more