pub trait SubscriptionObserver: Send + Sync {
// Required method
fn on_close(&self, close: SubscriptionClose);
}Expand description
Observes the terminal half of subscriptions/listen streams.
The request half of the observation boundary is ordinary
Service<RouterRequest> middleware: transports dispatch the listen
request through the service before upgrading, so a layer sees acceptance
and rejection like any other method. What that boundary cannot express is
the stream’s end, which happens long after the service call returns. This
hook carries exactly that remainder and nothing else: implement it for
ledger or audit records that need terminal reason and duration, and pair
it with a layer for the request half.
Attach with McpRouter::with_subscription_observer; every transport
that owns listen streams (stdio, generic stdio, bidirectional stdio,
channel, HTTP) reports through it. Calls are made from transport
internals, so implementations must be fast and non-blocking.
Required Methods§
Sourcefn on_close(&self, close: SubscriptionClose)
fn on_close(&self, close: SubscriptionClose)
A subscriptions/listen stream reached its end.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".