Struct axum::serve::WithGracefulShutdown
source · pub struct WithGracefulShutdown<M, S, F> { /* private fields */ }
Expand description
Serve future with graceful shutdown enabled.
Implementations§
source§impl<M, S, F> WithGracefulShutdown<M, S, F>
impl<M, S, F> WithGracefulShutdown<M, S, F>
sourcepub fn tcp_nodelay(self, nodelay: bool) -> Self
pub fn tcp_nodelay(self, nodelay: bool) -> Self
Instructs the server to set the value of the TCP_NODELAY
option on every accepted connection.
See also TcpStream::set_nodelay
.
§Example
use axum::{Router, routing::get};
let router = Router::new().route("/", get(|| async { "Hello, World!" }));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, router)
.with_graceful_shutdown(shutdown_signal())
.tcp_nodelay(true)
.await
.unwrap();
async fn shutdown_signal() {
// ...
}
sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Returns the local address this server is bound to.
Trait Implementations§
source§impl<M, S, F> Debug for WithGracefulShutdown<M, S, F>
impl<M, S, F> Debug for WithGracefulShutdown<M, S, F>
source§impl<M, S, F> IntoFuture for WithGracefulShutdown<M, S, F>where
M: for<'a> Service<IncomingStream<'a>, Error = Infallible, Response = S> + Send + 'static,
for<'a> <M as Service<IncomingStream<'a>>>::Future: Send,
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + 'static,
S::Future: Send,
F: Future<Output = ()> + Send + 'static,
impl<M, S, F> IntoFuture for WithGracefulShutdown<M, S, F>where
M: for<'a> Service<IncomingStream<'a>, Error = Infallible, Response = S> + Send + 'static,
for<'a> <M as Service<IncomingStream<'a>>>::Future: Send,
S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + 'static,
S::Future: Send,
F: Future<Output = ()> + Send + 'static,
§type IntoFuture = ServeFuture
type IntoFuture = ServeFuture
Which kind of future are we turning this into?
source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Auto Trait Implementations§
impl<M, S, F> !Freeze for WithGracefulShutdown<M, S, F>
impl<M, S, F> RefUnwindSafe for WithGracefulShutdown<M, S, F>
impl<M, S, F> Send for WithGracefulShutdown<M, S, F>
impl<M, S, F> Sync for WithGracefulShutdown<M, S, F>
impl<M, S, F> Unpin for WithGracefulShutdown<M, S, F>
impl<M, S, F> UnwindSafe for WithGracefulShutdown<M, S, F>
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