pub struct GracefulShutdownSignal { /* private fields */ }Expand description
Notification that the server has started a graceful shutdown.
The signal remains notified after graceful shutdown starts. A listener that calls
notified or clones this signal after that point is notified immediately.
A forced shutdown does not notify this signal.
§Server State
When this signal is notified, the Server has accepted a graceful shutdown
command, but shutdown is not complete. The server sends this notification before it tells the
accept loop and workers to stop. Therefore, a listener can briefly overlap with connection
acceptance and normal worker operation.
Very shortly after notification, the server stops accepting connections and tells each worker to
stop its services. Active service futures can continue until they finish or the
ServerBuilder::shutdown_timeout expires.
§Use Cases
Connection-oriented services can listen to this signal to coordinate their own drain process. For example, a protocol dispatcher can:
- close an idle persistent connection;
- stop accepting new logical requests on an active connection;
- let the current request or protocol operation finish; and
- start a protocol-specific close handshake or flush buffered data.
This signal does not replace the worker shutdown timeout. A listener must still finish its service future for the worker to complete a graceful shutdown.
Implementations§
Trait Implementations§
Source§impl Clone for GracefulShutdownSignal
impl Clone for GracefulShutdownSignal
Source§fn clone(&self) -> GracefulShutdownSignal
fn clone(&self) -> GracefulShutdownSignal
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more