pub struct ServerHandle { /* private fields */ }Expand description
Background-task handle returned by every spawn_* method.
Drop semantics: dropping the handle does not stop the server. Call
ServerHandle::shutdown (or ServerHandle::trigger + .join().await)
so the drain logic in the underlying serve_*_with_shutdown runs.
Runtime-agnostic — the done signal is fired by an async wrapper around
the underlying serve_* future, so the same ServerHandle works whether
the spawned task lives on the tokio runtime or the compio runtime.
Implementations§
Source§impl ServerHandle
impl ServerHandle
Sourcepub async fn join(&self)
pub async fn join(&self)
Await the spawned task’s completion (without triggering shutdown).
Returns when the underlying serve_* future resolves — typically
because ServerHandle::trigger / ServerHandle::shutdown was called
or because the listener errored fatally.
Sourcepub async fn shutdown(self, _timeout: Duration)
pub async fn shutdown(self, _timeout: Duration)
Trigger graceful shutdown and await the drain.
The _timeout argument is kept for API symmetry with the original
builder; the actual drain bound is the drain_timeout on the
ServerConfig that was handed to the builder, enforced inside
serve_*_with_shutdown.
Sourcepub fn drain_timeout(&self) -> Duration
pub fn drain_timeout(&self) -> Duration
Returns the drain timeout the underlying serve_* will honor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ServerHandle
impl RefUnwindSafe for ServerHandle
impl Send for ServerHandle
impl Sync for ServerHandle
impl Unpin for ServerHandle
impl UnsafeUnpin for ServerHandle
impl UnwindSafe for ServerHandle
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more