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
impl ChrononBuilder
Sourcepub fn scheduler_store(self, store: Arc<dyn SchedulerStore>) -> Self
pub fn scheduler_store(self, store: Arc<dyn SchedulerStore>) -> Self
Required unless Self::scheduler_store_from_global is used.
Sourcepub fn scheduler_store_from_global(self) -> Result<Self>
pub fn scheduler_store_from_global(self) -> Result<Self>
Installs the process-global default store (e.g. mem backend); errors if unset.
Sourcepub fn context_factory(self, factory: Arc<dyn ContextFactory>) -> Self
pub fn context_factory(self, factory: Arc<dyn ContextFactory>) -> Self
Factory used when executing scripts; defaults to NoOpContextFactory.
Sourcepub fn telemetry_sink(self, sink: Arc<dyn TelemetrySink>) -> Self
pub fn telemetry_sink(self, sink: Arc<dyn TelemetrySink>) -> Self
Metrics sink shared by scheduler and executor; defaults to NoOpSink.
Sourcepub fn script_registry(self, registry: Arc<ScriptRegistry>) -> Self
pub fn script_registry(self, registry: Arc<ScriptRegistry>) -> Self
Script registry for the executor; use Self::auto_registry to populate from inventory.
Sourcepub fn instance_id(self, id: impl Into<String>) -> Self
pub fn instance_id(self, id: impl Into<String>) -> Self
Stable id for scheduler leader election and worker rows; random UUID if omitted.
Sourcepub fn coordinator_only(self) -> Self
pub fn coordinator_only(self) -> Self
Coordinator-only: tick and partition assigner, no worker slots.
Sourcepub fn worker(self, pool_id: impl Into<String>) -> Self
pub fn worker(self, pool_id: impl Into<String>) -> Self
Worker-only: claim and execute runs for pool_id.
Sourcepub fn remote_coordinator(self, base_url: impl Into<String>) -> Self
pub fn remote_coordinator(self, base_url: impl Into<String>) -> Self
Remote client shape: no local loops; pair with crate::RemoteCoordinatorClient.
Sourcepub fn auto_registry(self) -> Self
pub fn auto_registry(self) -> Self
Populate registry from inventory (#[chronon::script] link-time registration).
Sourcepub fn tick_interval_ms(self, ms: u64) -> Self
pub fn tick_interval_ms(self, ms: u64) -> Self
Scheduler tick period in milliseconds; overrides CHRONON_TICK_INTERVAL_MS when set.
Sourcepub fn build(self) -> Result<Chronon>
pub fn build(self) -> Result<Chronon>
Assemble crate::Chronon; returns ChrononError::Internal if store was not configured.