Skip to main content

bestool_alertd/http_server/
state.rs

1use std::{collections::HashMap, sync::Arc, time::Duration};
2
3use jiff::Timestamp;
4
5use crate::{context::InternalContext, daemon::DaemonControl, tasks::TaskEndpointHandler};
6
7#[derive(Clone)]
8pub struct ServerState {
9	pub started_at: Timestamp,
10	pub pid: u32,
11	pub internal_context: Arc<InternalContext>,
12	pub watchdog_timeout: Option<Duration>,
13	/// Endpoint handlers exposed by registered background tasks. Keyed by
14	/// `(task_name, endpoint_name)` so the `/tasks/:task/:endpoint` route can
15	/// dispatch in O(1) without walking the task registry per request.
16	pub task_endpoints: Arc<HashMap<(String, String), TaskEndpointHandler>>,
17	/// Drives the daemon's `/reload` and `/restart` control endpoints.
18	pub control: DaemonControl,
19	/// Backup run registry, when backups are compiled in; lets `/status` list
20	/// in-flight runs.
21	pub backups: Option<Arc<crate::BackupRegistry>>,
22}