Skip to main content

Chronon

Struct Chronon 

Source
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:

  1. Upsert jobs through Self::coordinator_service (or HTTP / remote client).
  2. Call Self::run to start shape-specific loops (or Self::tick_once in tests).
  3. Call Self::shutdown on exit.
DeploymentShapeSelf::run behavior
EmbeddedTick + worker in this process
CoordinatorOnlyTick + 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: CoordinatorService

Job/run CRUD facade over Self::store.

§deployment: DeploymentShape

Deployment shape selected at build time.

Implementations§

Source§

impl Chronon

Source

pub fn shutdown(&self)

Signal all runtime loops to stop.

Source

pub fn shutdown_handle(&self) -> Arc<Notify>

Shared shutdown signal for background Self::run tasks (testkit / host wiring).

Source

pub async fn run(&mut self) -> Result<()>

Run deployment loops until Self::shutdown is called.

Dispatches on Self::deployment:

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.

Source

pub async fn tick_once(&self) -> Result<TickResult>

Advance the scheduler by one tick (tests and manual stepping).

Source

pub fn coordinator_service(&self) -> &CoordinatorService

Job and run CRUD for HTTP handlers and host integration.

Source

pub fn executor(&self) -> &Executor

Script executor (registry + dispatch).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more