pub struct ConfigSnapshot { /* private fields */ }Expand description
A configuration pinned for one request transaction. Obtain via crate::Control::snapshot;
run on_request then (later) on_response against the same snapshot so a reload cannot
desync the two halves.
The snapshot also carries the request’s RequestTrace (ADR 000009): both halves run
under one trace context, so the request-side and response-side filter spans belong to the
same trace. The host emits those spans to its sink as the chain runs.
Clone is cheap (an Arc clone + the trace ids) and yields the same pinned config and
trace — the fast-path server clones one snapshot to run the request and response halves on
separate spawn_blocking tasks while keeping them in one transaction (ADR 000013).
Implementations§
Source§impl ConfigSnapshot
impl ConfigSnapshot
Sourcepub fn on_request(&self, request: HttpRequest) -> ChainOutcome
pub fn on_request(&self, request: HttpRequest) -> ChainOutcome
Drive a request through the default [chain] (the chain-only convenience). The
fast-path server uses ConfigSnapshot::find_route + ConfigSnapshot::dispatch_request.
Sourcepub fn on_response(
&self,
request: &HttpRequest,
response: HttpResponse,
) -> ResponseOutcome
pub fn on_response( &self, request: &HttpRequest, response: HttpResponse, ) -> ResponseOutcome
Drive a response back through the default [chain] in reverse. request is the
as-forwarded request snapshot every response hook sees (ADR 000073).
Sourcepub fn find_route(&self, request: &HttpRequest) -> Option<RouteInfo>
pub fn find_route(&self, request: &HttpRequest) -> Option<RouteInfo>
Match a request to a route by its [route.match] dimensions — host, path prefix, method,
headers, query (ADR 000013 / 000034) — or None when no route matches (the server responds
404). The most specific match wins (see [route::select]). Pure config lookup — cheap and
non-blocking, so it runs on the async thread; only the returned route’s chain dispatch is
blocking work. Reads only borrowed request fields, so matching is allocation-free.
Sourcepub fn dispatch_request(
&self,
route: usize,
request: HttpRequest,
) -> ChainOutcome
pub fn dispatch_request( &self, route: usize, request: HttpRequest, ) -> ChainOutcome
Drive a request through a matched route’s chain (request side). route is the index from
ConfigSnapshot::find_route on this same snapshot. Returns forward-or-respond just like
on_request. Out-of-range (a stale index from another snapshot) responds with a
fail-closed 404 rather than panicking (data-plane no-panic, bp-rust).
Sourcepub fn dispatch_request_body(
&self,
route: usize,
body: Vec<u8>,
) -> RequestBodyOutcome
pub fn dispatch_request_body( &self, route: usize, body: Vec<u8>, ) -> RequestBodyOutcome
Drive a buffered request body through a matched route’s on-request-body chain (ADR 000025).
Same route index as the request side, on the same snapshot. The server calls this only for a
route with filters and a non-empty body; a stale index forwards the body unchanged.
Sourcepub fn dispatch_response(
&self,
route: usize,
request: &HttpRequest,
response: HttpResponse,
) -> ResponseOutcome
pub fn dispatch_response( &self, route: usize, request: &HttpRequest, response: HttpResponse, ) -> ResponseOutcome
Drive a response back through a matched route’s chain in reverse. Same route index as
the request side, on the same (cloned) snapshot, so both halves run one route’s chain.
request is the as-forwarded request snapshot (ADR 000073). A stale index forwards the
response unchanged (fail-soft, same as the other dispatch_*).
Sourcepub fn config_version(&self) -> &str
pub fn config_version(&self) -> &str
The config version (manifest content hash) this transaction is pinned to.
Sourcepub fn traceparent(&self) -> String
pub fn traceparent(&self) -> String
The W3C traceparent for this transaction — pass downstream so the upstream request
continues the same trace (ADR 000009 propagation).
Trait Implementations§
Source§impl Clone for ConfigSnapshot
impl Clone for ConfigSnapshot
Source§fn clone(&self) -> ConfigSnapshot
fn clone(&self) -> ConfigSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ConfigSnapshot
impl !UnwindSafe for ConfigSnapshot
impl Freeze for ConfigSnapshot
impl Send for ConfigSnapshot
impl Sync for ConfigSnapshot
impl Unpin for ConfigSnapshot
impl UnsafeUnpin for ConfigSnapshot
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more