Skip to content

Commit

Permalink
Update graceful shutdown example on type as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
bittrance committed Jul 6, 2024
1 parent 5703338 commit 4e01db4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions axum/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,21 +287,22 @@ impl<M, S, F> WithGracefulShutdown<M, S, F> {
/// # Example
/// ```
/// use axum::{Router, routing::get};
/// use std::{future::IntoFuture, sync::Arc};
/// 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 {
Expand Down

0 comments on commit 4e01db4

Please sign in to comment.