haystack_server/state.rs
1//! Application state shared across all request handlers.
2
3use haystack_core::graph::SharedGraph;
4use haystack_core::ontology::DefNamespace;
5
6use crate::actions::ActionRegistry;
7use crate::auth::AuthManager;
8use crate::federation::Federation;
9use crate::his_store::HisStore;
10use crate::ws::WatchManager;
11
12/// Shared application state injected into every Actix handler via `web::Data`.
13pub struct AppState {
14 /// Thread-safe entity graph.
15 pub graph: SharedGraph,
16 /// Haystack 4 ontology namespace for def/spec operations.
17 pub namespace: parking_lot::RwLock<DefNamespace>,
18 /// SCRAM authentication manager.
19 pub auth: AuthManager,
20 /// Watch subscription manager for change polling.
21 pub watches: WatchManager,
22 /// Action dispatch registry for the `invokeAction` op.
23 pub actions: ActionRegistry,
24 /// In-memory time-series history store for hisRead/hisWrite.
25 pub his: HisStore,
26 /// Instant when the server was started, used for uptime calculation.
27 pub started_at: std::time::Instant,
28 /// Federation manager for remote connector queries.
29 pub federation: Federation,
30}