Skip to main content

max / makenotwork

837 B · 26 lines History Blame Raw
1 use crate::config::Config;
2 use crate::domain::{AppId, Target};
3 use crate::events::EventTx;
4 use crate::ota::OtaRegistry;
5 use crate::topology::Topology;
6 use metrics_exporter_prometheus::PrometheusHandle;
7 use sqlx::SqlitePool;
8 use std::collections::HashMap;
9 use std::sync::Arc;
10 use tokio::sync::Mutex;
11 use tokio::task::AbortHandle;
12
13 #[derive(Clone)]
14 pub struct AppState {
15 pub pool: SqlitePool,
16 pub topo: Arc<Topology>,
17 pub cfg: Arc<Config>,
18 pub prom: PrometheusHandle,
19 pub events: EventTx,
20 pub ota: Arc<OtaRegistry>,
21 /// Single-slot guard per `(app, target)`: a newer build for the same
22 /// target aborts the in-flight one (latest request wins), mirroring
23 /// Sando's `active_build`. Other targets keep running — that's the fan-out.
24 pub active: Arc<Mutex<HashMap<(AppId, Target), AbortHandle>>>,
25 }
26