Skip to main content

ChrononBuilder

Struct ChrononBuilder 

Source
pub struct ChrononBuilder { /* private fields */ }
Expand description

Builds a crate::Chronon runtime with explicit adapter injection.

Hosts call fluent setters then Self::build. Missing store is the only hard requirement; context factory, telemetry, and registry fall back to no-op defaults.

§Examples

use std::sync::Arc;
use chronon_backend_mem::InMemorySchedulerStore;
use chronon_runtime::ChrononBuilder;

let store = Arc::new(InMemorySchedulerStore::new());
let chronon = ChrononBuilder::new()
    .scheduler_store(store)
    .embedded()
    .build()
    .unwrap();
assert_eq!(chronon.executor().script_count(), 0);

Implementations§

Source§

impl ChrononBuilder

Source

pub fn new() -> Self

Empty builder: embedded deployment, env-default tick interval, no store.

Source

pub fn scheduler_store(self, store: Arc<dyn SchedulerStore>) -> Self

Required unless Self::scheduler_store_from_global is used.

Source

pub fn scheduler_store_from_global(self) -> Result<Self>

Installs the process-global default store (e.g. mem backend); errors if unset.

Source

pub fn context_factory(self, factory: Arc<dyn ContextFactory>) -> Self

Factory used when executing scripts; defaults to NoOpContextFactory.

Source

pub fn telemetry_sink(self, sink: Arc<dyn TelemetrySink>) -> Self

Metrics sink shared by scheduler and executor; defaults to NoOpSink.

Source

pub fn script_registry(self, registry: Arc<ScriptRegistry>) -> Self

Script registry for the executor; use Self::auto_registry to populate from inventory.

Source

pub fn instance_id(self, id: impl Into<String>) -> Self

Stable id for scheduler leader election and worker rows; random UUID if omitted.

Source

pub fn embedded(self) -> Self

Embedded coordinator + worker loops in one process.

Source

pub fn coordinator_only(self) -> Self

Coordinator-only: tick and partition assigner, no worker slots.

Source

pub fn worker(self, pool_id: impl Into<String>) -> Self

Worker-only: claim and execute runs for pool_id.

Source

pub fn remote_coordinator(self, base_url: impl Into<String>) -> Self

Remote client shape: no local loops; pair with crate::RemoteCoordinatorClient.

Source

pub fn auto_registry(self) -> Self

Populate registry from inventory (#[chronon::script] link-time registration).

Source

pub fn tick_interval_ms(self, ms: u64) -> Self

Scheduler tick period in milliseconds; overrides CHRONON_TICK_INTERVAL_MS when set.

Source

pub fn build(self) -> Result<Chronon>

Assemble crate::Chronon; returns ChrononError::Internal if store was not configured.

Trait Implementations§

Source§

impl Default for ChrononBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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