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("0.0.0.0: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§
Source§impl Clone for ShutdownHandle
impl Clone for ShutdownHandle
Source§fn clone(&self) -> ShutdownHandle
fn clone(&self) -> ShutdownHandle
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ShutdownHandle
impl RefUnwindSafe for ShutdownHandle
impl Send for ShutdownHandle
impl Sync for ShutdownHandle
impl Unpin for ShutdownHandle
impl UnsafeUnpin for ShutdownHandle
impl UnwindSafe for ShutdownHandle
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