pub struct HttpInspectionLayer { /* private fields */ }Expand description
A Layer that observes HTTP responses and invokes registered callbacks based on their status code.
Inspectors are registered against a specific StatusCode via with_inspector. Whenever
the wrapped service produces a successful (Ok) response whose status matches, the corresponding callback is
invoked. Multiple inspectors may be registered, including more than one for the same status, in which case all
matching callbacks are invoked. The response itself is always passed through unchanged, and service errors never
trigger callbacks.
This layer is purely observational: it does not modify requests or responses, retry, or short-circuit. Because it sees the raw response from the inner service, placing it below a layer that transforms responses into errors (such as a retry circuit breaker) allows callbacks to observe responses that would otherwise never surface to the caller.
Callbacks are invoked from within the response future, which may be polled concurrently, so they must be Send and
Sync. Any throttling or deduplication of callback invocations is the caller’s responsibility.
Implementations§
Source§impl HttpInspectionLayer
impl HttpInspectionLayer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new HttpInspectionLayer with no registered inspectors.
Without any inspectors, the layer passes every response through unchanged and invokes nothing.
Sourcepub fn with_inspector<F>(self, status: StatusCode, callback: F) -> Self
pub fn with_inspector<F>(self, status: StatusCode, callback: F) -> Self
Registers a callback to be invoked whenever a response with the given status code is observed.
The callback is invoked once per matching response, including responses produced by retried requests when this layer sits below a retrying layer.
Trait Implementations§
Source§impl Clone for HttpInspectionLayer
impl Clone for HttpInspectionLayer
Source§fn clone(&self) -> HttpInspectionLayer
fn clone(&self) -> HttpInspectionLayer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for HttpInspectionLayer
impl Default for HttpInspectionLayer
Source§fn default() -> HttpInspectionLayer
fn default() -> HttpInspectionLayer
Auto Trait Implementations§
impl Freeze for HttpInspectionLayer
impl !RefUnwindSafe for HttpInspectionLayer
impl Send for HttpInspectionLayer
impl Sync for HttpInspectionLayer
impl Unpin for HttpInspectionLayer
impl !UnwindSafe for HttpInspectionLayer
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Track for T
impl<T> Track for T
Source§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read moreSource§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more