chronon_axum/state.rs
1//! Shared state for Chronon API handlers.
2
3use std::sync::Arc;
4
5use chronon_executor::ScriptRegistry;
6use chronon_runtime::CoordinatorService;
7
8/// Shared state for Chronon API handlers.
9///
10/// Install on the host router via [`axum::extract::FromRef`] and pass to [`crate::chronon_router`].
11#[derive(Clone)]
12pub struct ChrononState {
13 /// Job and run persistence facade.
14 pub coordinator: Arc<CoordinatorService>,
15 /// Script catalog for upsert validation and `GET /scripts`.
16 pub registry: Arc<ScriptRegistry>,
17}
18
19impl ChrononState {
20 /// Build handler state from coordinator and registry arcs.
21 pub fn new(coordinator: Arc<CoordinatorService>, registry: Arc<ScriptRegistry>) -> Self {
22 Self {
23 coordinator,
24 registry,
25 }
26 }
27}