|
134 | 134 | //! - [Simple]: the full simple example from above |
135 | 135 | //! - [Axum]: the full axum example from above |
136 | 136 | //! - [Tokio]: the full tokio example from above |
137 | | -//! - [Hyper]: a shutdown example using the Hyper webserver |
138 | 137 | //! - [Worker]: example implementation of a worker using `select!` |
139 | 138 | //! - [Smol]: example using the smol runtime |
140 | 139 | //! - [Async Std]: example using the async_std runtime |
|
143 | 142 | //! [Simple]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/simple.rs |
144 | 143 | //! [Axum]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/axum.rs |
145 | 144 | //! [Tokio]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/tokio.rs |
146 | | -//! [Hyper]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/hyper.rs |
147 | 145 | //! [Worker]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/worker.rs |
148 | 146 | //! [Smol]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/smol.rs |
149 | 147 | //! [Async Std]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/async_std.rs |
@@ -253,37 +251,6 @@ pub fn get_shutdown_guard() -> ShutdownGuard { |
253 | 251 | /// |
254 | 252 | /// This function is usually not required. Typically you would await |
255 | 253 | /// the future returned by [shutdown] instead or use a [guard](get_shutdown_guard). |
256 | | -/// |
257 | | -/// # Example: |
258 | | -/// |
259 | | -/// ```no_run |
260 | | -/// use hyper::{ |
261 | | -/// service::{make_service_fn, service_fn}, |
262 | | -/// Body, Request, Response, Server, |
263 | | -/// }; |
264 | | -/// use std::convert::Infallible; |
265 | | -/// |
266 | | -/// async fn good_bye_world(_: Request<Body>) -> Result<Response<Body>, Infallible> { |
267 | | -/// // initiate a shutdown but don't wait for it to complete |
268 | | -/// let _ = elegant_departure::shutdown(); |
269 | | -/// Ok(Response::new(Body::from("Good bye World!"))) |
270 | | -/// } |
271 | | -/// |
272 | | -/// #[tokio::main] |
273 | | -/// async fn main() { |
274 | | -/// let svc = make_service_fn(|_| async { Ok::<_, Infallible>(service_fn(good_bye_world)) }); |
275 | | -/// |
276 | | -/// let addr = ([127, 0, 0, 1], 3000).into(); |
277 | | -/// let server = Server::bind(&addr).serve(svc); |
278 | | -/// |
279 | | -/// server |
280 | | -/// // Only exit after the shutdown has completed. |
281 | | -/// // If hyper was started as a task you would wait on a guard here instead. |
282 | | -/// .with_graceful_shutdown(elegant_departure::wait_for_shutdown_complete()) |
283 | | -/// .await |
284 | | -/// .unwrap(); |
285 | | -/// } |
286 | | -/// ``` |
287 | 254 | pub fn wait_for_shutdown_complete() -> impl Future<Output = ()> + Send { |
288 | 255 | REGISTRY.lock().unwrap().wait_for_shutdown_complete() |
289 | 256 | } |
@@ -313,18 +280,6 @@ pub fn wait_for_shutdown_complete() -> impl Future<Output = ()> + Send { |
313 | 280 | /// elegant_departure::shutdown().await; |
314 | 281 | /// } |
315 | 282 | /// ``` |
316 | | -/// |
317 | | -/// Shutdown initited from a hyper service: |
318 | | -/// |
319 | | -/// ```no_run |
320 | | -/// # use std::convert::Infallible; |
321 | | -/// # use hyper::{Body, Request, Response}; |
322 | | -/// async fn good_bye_world(_: Request<Body>) -> Result<Response<Body>, Infallible> { |
323 | | -/// // initiate a shutdown but don't wait for it to complete |
324 | | -/// drop(elegant_departure::shutdown()); |
325 | | -/// Ok(Response::new(Body::from("Good bye World!"))) |
326 | | -/// } |
327 | | -/// ``` |
328 | 283 | pub fn shutdown() -> impl Future<Output = ()> + Send { |
329 | 284 | REGISTRY.lock().unwrap().shutdown(); |
330 | 285 | REGISTRY.lock().unwrap().wait_for_shutdown_complete() |
|
0 commit comments