pub struct ShutdownHandle { /* private fields */ }Expand description
Handle for triggering graceful server shutdown.
Returned by ServerBuilder::build_with_shutdown. Pass the future from
ShutdownHandle::signal() to axum::serve(...).with_graceful_shutdown()
to enable both OS signal-based and HTTP endpoint-based shutdown.
§Example
ⓘ
use adk_server::{ServerBuilder, ServerConfig};
let (app, shutdown_handle) = ServerBuilder::new(config)
.enable_shutdown_endpoint()
.build_with_shutdown();
let listener = tokio::net::TcpListener::bind("127.0.0.1:8080").await?;
axum::serve(listener, app)
.with_graceful_shutdown(shutdown_handle.signal())
.await?;Implementations§
Source§impl ShutdownHandle
impl ShutdownHandle
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Trigger graceful shutdown programmatically.
This has the same effect as calling POST /api/shutdown — the server
stops accepting new connections and completes in-flight requests.
Sourcepub async fn signal(self)
pub async fn signal(self)
Returns a future that resolves when shutdown is triggered.
Combines OS signals (Ctrl+C, SIGTERM) with the programmatic/HTTP trigger.
Pass this to axum::serve(...).with_graceful_shutdown().
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Returns whether shutdown has been triggered.
Trait Implementations§
Auto Trait Implementations§
impl Forget for ShutdownHandle
impl Freeze for ShutdownHandle
impl Move for ShutdownHandle
impl RefUnwindSafe for ShutdownHandlewhere
CancellationToken: RefUnwindSafe,
impl Send for ShutdownHandle
impl Sync for ShutdownHandle
impl Unpin for ShutdownHandle
impl UnsafeUnpin for ShutdownHandlewhere
*const ArcInner<TreeNode> is !null: UnsafeUnpin,
PhantomData<ArcInner<TreeNode>>: UnsafeUnpin,
impl UnwindSafe for ShutdownHandlewhere
CancellationToken: UnwindSafe,
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
Mutably borrows from an owned value. Read more
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,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
Converts
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> ⓘ
Converts
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