antithesis_intake/http/
state.rs

1//! Shared state carried by each HTTP router.
2
3use std::sync::{Arc, OnceLock};
4
5use crate::capture;
6
7/// Per-router state: the shared recorder handle plus the lane this router writes to.
8#[derive(Clone, Debug)]
9pub struct AppState {
10    pub(crate) recorder: capture::State,
11    pub(crate) target: capture::Target,
12    /// First non-empty host resolved on this lane, set once. Pyld17 requires every series across all
13    /// inbound traffic on the lane to resolve to this same host.
14    pub(crate) established_host: Arc<OnceLock<String>>,
15}
16
17impl AppState {
18    /// Creates router state for Datadog Agent intake.
19    #[must_use]
20    pub fn agent(recorder: &capture::State) -> Self {
21        Self {
22            recorder: recorder.clone(),
23            target: capture::Target::Agent,
24            established_host: Arc::default(),
25        }
26    }
27
28    /// Creates router state for ADP intake.
29    #[must_use]
30    pub fn adp(recorder: &capture::State) -> Self {
31        Self {
32            recorder: recorder.clone(),
33            target: capture::Target::Adp,
34            established_host: Arc::default(),
35        }
36    }
37}