pub struct WriteContext {
pub originator: Originator,
pub interface: Option<String>,
pub request_id: Option<String>,
}Expand description
Per-request write context — set at the request entry point
(HTTP/MQTT/gRPC dispatcher) and read by the backend logging layer
to populate the corresponding fields on the LogEntry.
Threaded as a tokio task-local so that intermediate layers don’t
have to pass Originator / interface / request id through every
function signature. The HTTP dispatcher wraps each request future
in WRITE_CTX::scope; any backend write that happens inside the
scoped future reads the context and stamps the resulting log entry
accordingly.
When no scope is active (background tasks, startup bootstrap,
internal sweeps), current_write_context returns
WriteContext::internal with component = "yeti-host" so the
log still records a meaningful originator.
Fields§
§originator: OriginatorWho initiated the write.
interface: Option<String>Which protocol the write came in through — "rest", "graphql",
"mqtt", "mcp", "internal". None when not derivable.
request_id: Option<String>Optional request correlation id (e.g., the HTTP x-request-id
header value or a generated UUID).
Implementations§
Source§impl WriteContext
impl WriteContext
Sourcepub fn internal() -> Self
pub fn internal() -> Self
The default fallback used when no scope is active. Marks the write as originating from the yeti-host platform itself.
Sourcepub fn for_request(
interface: impl Into<String>,
user: Option<String>,
request_id: Option<String>,
) -> Self
pub fn for_request( interface: impl Into<String>, user: Option<String>, request_id: Option<String>, ) -> Self
Construct a WriteContext for a request that came in through
the named interface, identifying the authenticated user when
known.
Sourcepub fn for_replication(from_node: impl Into<String>) -> Self
pub fn for_replication(from_node: impl Into<String>) -> Self
Construct a WriteContext for a write applied locally in
response to a peer’s replication stream.
Trait Implementations§
Source§impl Clone for WriteContext
impl Clone for WriteContext
Source§fn clone(&self) -> WriteContext
fn clone(&self) -> WriteContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more