pub struct ServerShutdown { /* private fields */ }pubsub only.Expand description
The shutdown signal for some server. When dropped, will cancel all tasks
associated with the running server. This includes all running Handlers,
as well as pubsub connection management tasks (if running).
The shutdown wraps a TaskTracker and a CancellationToken, and
exposes methods from those APIs. Please see the documentation for those
types for more information.
Implementations§
Source§impl ServerShutdown
impl ServerShutdown
Sourcepub fn wait(&self) -> TaskTrackerWaitFuture<'_>
pub fn wait(&self) -> TaskTrackerWaitFuture<'_>
Wait for the tasks spawned by the server to complete. This is a wrapper
for TaskTracker::wait, and allows outside code to wait for the
server to signal that it has completely shut down.
This future will not resolve until both of the following are true:
Self::closehas been called.- All tasks spawned by the server have finished running.
Sourcepub fn close(&self)
pub fn close(&self)
Close the intenal TaskTracker, cancelling all running tasks, and
allowing Self::wait futures to resolve, provided all tasks are
complete.
This will not cancel running tasks, and will not prevent new tasks from being spawned.
See TaskTracker::close for more information.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Check if the server’s internal TaskTracker has been closed. This
does not indicate that all tasks have completed, or that the server has
been cancelled. See TaskTracker::is_closed for more information.
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Issue a cancellation signal to all tasks spawned by the server. This
will immediately cancel tasks spawned with the HandlerCtx::spawn
family of methods, and will issue cancellation signals to tasks
spawned with HandlerCtx::spawn_graceful family of methods.
This will also cause new tasks spawned by the server to be immediately cancelled, or notified of cancellation.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if the server has been cancelled. true indicates that the
server has been instructed to shut down, and all tasks have either been
cancelled, or have received a notification that they should shut down.
Sourcepub fn cancelled(&self) -> WaitForCancellationFuture<'_>
pub fn cancelled(&self) -> WaitForCancellationFuture<'_>
Get a future that resolves when the server has been cancelled. This
future will resolve when Self::cancel has been called, and all
tasks have been issued a cancellation signal.
Sourcepub async fn shutdown(self)
pub async fn shutdown(self)
Shutdown the server, and wait for all tasks to complete.
This is equivalent to calling Self::cancel, Self::close and
then awaiting Self::wait.