heldar_kernel/state.rs
1use std::sync::Arc;
2
3use chrono::{DateTime, Utc};
4use sqlx::SqlitePool;
5
6use crate::config::Config;
7use crate::services::consumer::DetectionConsumer;
8use crate::services::mirror::MirrorRecorderManager;
9use crate::services::recorder::RecorderManager;
10use crate::services::sampler::SamplerManager;
11
12/// Shared application state, cloned cheaply into every handler and background task.
13///
14/// Note the kernel holds NO concrete domain engine: perception interpreters (zones, ANPR/entry, and
15/// future apps) are registered as [`DetectionConsumer`]s in `consumers`, so the ingest path and this
16/// struct stay domain-agnostic. After the crate split the composing binary decides which app crates
17/// populate the registry.
18#[derive(Clone)]
19pub struct AppState {
20 pub pool: SqlitePool,
21 pub cfg: Arc<Config>,
22 pub recorder: Arc<RecorderManager>,
23 /// Dual/mirror recorder, present only when `HELDAR_MIRROR_RECORDINGS_DIR` is configured.
24 pub mirror: Option<Arc<MirrorRecorderManager>>,
25 pub sampler: Arc<SamplerManager>,
26 /// Registered perception consumers, fanned out to from detection ingest.
27 pub consumers: Arc<Vec<Arc<dyn DetectionConsumer>>>,
28 pub http: reqwest::Client,
29 pub started_at: DateTime<Utc>,
30}