Skip to main content

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::recorder::RecorderManager;
9use crate::services::sampler::SamplerManager;
10
11/// Shared application state, cloned cheaply into every handler and background task.
12///
13/// Note the kernel holds NO concrete domain engine: perception interpreters (zones, ANPR/entry, and
14/// future apps) are registered as [`DetectionConsumer`]s in `consumers`, so the ingest path and this
15/// struct stay domain-agnostic. After the crate split the composing binary decides which app crates
16/// populate the registry.
17#[derive(Clone)]
18pub struct AppState {
19    pub pool: SqlitePool,
20    pub cfg: Arc<Config>,
21    pub recorder: Arc<RecorderManager>,
22    pub sampler: Arc<SamplerManager>,
23    /// Registered perception consumers, fanned out to from detection ingest.
24    pub consumers: Arc<Vec<Arc<dyn DetectionConsumer>>>,
25    pub http: reqwest::Client,
26    pub started_at: DateTime<Utc>,
27}