1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! Per-request execution context.
//!
//! [`RequestContext`] carries the cross-cutting facts about the work in flight —
//! a generated request id, an inbound correlation id, tenant and principal,
//! locale, when it arrived, an optional deadline, and a free-form metadata bag.
//!
//! There are two ways to use it, by design:
//!
//! * **Explicit** (always available): construct a `RequestContext` and pass
//! `&ctx` down the call chain. This is the source of truth — clear and testable.
//! * **Ambient** (feature `task-local`): set the context once for a request with
//! [`RequestContext::scope`] and read it anywhere below with
//! [`RequestContext::try_current`], without threading it through every signature.
//!
//! ```
//! use klauthed_core::context::RequestContext;
//!
//! let ctx = RequestContext::new()
//! .with_correlation_id("trace-abc")
//! .with_tenant("acme")
//! .with_metadata("feature_flag", "beta");
//!
//! assert!(ctx.correlation_id().is_some());
//! assert_eq!(ctx.tenant(), Some("acme"));
//! assert_eq!(ctx.metadata_get("feature_flag"), Some("beta"));
//! ```
use crateId;
pub use RequestContext;
/// Marker tag for a request identifier.
;
/// The id minted for each incoming request.
pub type RequestId = ;