pub struct GrpcHandle { /* private fields */ }Expand description
A handle to the gRPC server of one plugin.
Get it from GrpcPlugin::handle before
boot, or from AppState after boot:
let handle = state.extension::<GrpcHandle>().expect("gRPC plugin");The plugin calls shutdown when the app stops. Call it
yourself to drain earlier.
Implementations§
Source§impl GrpcHandle
impl GrpcHandle
Sourcepub fn local_addr(&self) -> Option<SocketAddr>
pub fn local_addr(&self) -> Option<SocketAddr>
The bound address. None before start, and always None with
listener = "shared". With port 0, this is the real port.
Sourcepub fn health_reporter(&self) -> Option<HealthReporter>
pub fn health_reporter(&self) -> Option<HealthReporter>
The health reporter, when the health service is on. Use it to mark
a service NOT_SERVING at runtime.
Sourcepub fn shutdown_grace(&self) -> Duration
pub fn shutdown_grace(&self) -> Duration
The drain time that shutdown allows. It is
shutdown_grace_ms, capped by Autumn’s server.shutdown_timeout_secs.
Sourcepub fn metric_families(&self) -> Vec<MetricFamily>
pub fn metric_families(&self) -> Vec<MetricFamily>
The current grpc_server_* metric families.
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Stop the server.
- Set every health status to
NOT_SERVING. - Stop accepting connections. Tell clients to go away (HTTP/2
GOAWAY). - Wait for in-flight calls, up to the grace period.
- Close the connections that are still open.
With listener = "shared", Autumn owns the connections. Steps 2 and
4 change: the plugin answers new calls with UNAVAILABLE, and it
ends open calls with UNAVAILABLE. The drain also starts by itself
when Autumn stops its listener.
A task does the drain. If you drop this future, the drain continues. You can call this method more than once, from many tasks. Each call returns after the server stops.
Trait Implementations§
Source§impl Clone for GrpcHandle
impl Clone for GrpcHandle
Auto Trait Implementations§
impl !RefUnwindSafe for GrpcHandle
impl !UnwindSafe for GrpcHandle
impl Forget for GrpcHandle
impl Freeze for GrpcHandle
impl Send for GrpcHandle
impl Sync for GrpcHandle
impl Unpin for GrpcHandle
impl UnsafeUnpin for GrpcHandle
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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::Requestimpl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.