ServerShutdown

Struct ServerShutdown 

Source
pub struct ServerShutdown { /* private fields */ }
Available on crate feature 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

Source

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::close has been called.
  • All tasks spawned by the server have finished running.
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ServerShutdown

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for ServerShutdown

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,