mirror of
https://github.com/tokio-rs/axum.git
synced 2025-03-02 14:58:25 +01:00
Update graceful shutdown example on type as well.
This commit is contained in:
parent
5c2ed13e84
commit
2a3a009c21
1 changed files with 10 additions and 9 deletions
|
@ -287,21 +287,22 @@ impl<M, S, F> WithGracefulShutdown<M, S, F> {
|
|||
/// # Example
|
||||
/// ```
|
||||
/// use axum::{Router, routing::get};
|
||||
/// use std::future::IntoFuture;
|
||||
/// use tokio::sync::oneshot;
|
||||
///
|
||||
/// # async {
|
||||
/// 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();
|
||||
/// let (tx, rx) = oneshot::channel();
|
||||
/// tokio::spawn(
|
||||
/// axum::serve(listener, router)
|
||||
/// .with_graceful_shutdown(async move { rx.await.unwrap_or(()) })
|
||||
/// .into_future(),
|
||||
/// );
|
||||
/// // ...
|
||||
/// tx.send(()).unwrap();
|
||||
/// # };
|
||||
///
|
||||
/// async fn shutdown_signal() {
|
||||
/// // ...
|
||||
/// }
|
||||
/// ```
|
||||
pub fn tcp_nodelay(self, nodelay: bool) -> Self {
|
||||
Self {
|
||||
|
|
Loading…
Add table
Reference in a new issue