Skip to content

Commit 00eb514

Browse files
committed
example: upgrades deps, removes hyper example
Hyper 1.0 is just way to much boilerplate to reproduce the simple example that existed before. Anyone capable of setting up hyper 1.0 is also capable of introducing `elegant-departure`.
1 parent 749a34d commit 00eb514

4 files changed

Lines changed: 2 additions & 101 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ tokio = { version = "1", features = ["signal"], optional = true }
1818

1919
[dev-dependencies]
2020
tokio = { version = "1", features = ["full"] }
21-
hyper = { version = "0.14", features = ["server", "tcp", "http1"] }
2221
async-std = { version = "1", features = ["attributes"] }
23-
smol = "1"
22+
smol = "2"
2423
anyhow = "1"
2524
serial_test = "3"
26-
axum = "0.7"
25+
axum = "0.8"
2726

2827
[[example]]
2928
name = "simple"
@@ -36,10 +35,6 @@ required-features = ["tokio"]
3635
name = "tokio"
3736
required-features = ["tokio"]
3837

39-
[[example]]
40-
name = "hyper"
41-
required-features = ["tokio"]
42-
4338
[[example]]
4439
name = "worker"
4540
required-features = ["tokio"]

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ Examples can be found in the [example](./examples/) directory:
4545
- [Simple](./examples/simple.rs): simple example without tokio integration
4646
- [Axum](./examples/axum.rs): Axum integration example
4747
- [Tokio](./examples/tokio.rs): Tokio integration example
48-
- [Hyper](./examples/hyper.rs): a shutdown example using the Hyper webserver
4948
- [Worker](./examples/worker.rs): example implementation of a worker using `select!`
5049
- [Smol](./examples/smol.rs): example using the smol runtime
5150
- [Async Std](./examples/async_std.rs): example using the async_std runtime

examples/hyper.rs

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/lib.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@
134134
//! - [Simple]: the full simple example from above
135135
//! - [Axum]: the full axum example from above
136136
//! - [Tokio]: the full tokio example from above
137-
//! - [Hyper]: a shutdown example using the Hyper webserver
138137
//! - [Worker]: example implementation of a worker using `select!`
139138
//! - [Smol]: example using the smol runtime
140139
//! - [Async Std]: example using the async_std runtime
@@ -143,7 +142,6 @@
143142
//! [Simple]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/simple.rs
144143
//! [Axum]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/axum.rs
145144
//! [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
147145
//! [Worker]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/worker.rs
148146
//! [Smol]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/smol.rs
149147
//! [Async Std]: https://github.com/Dav1dde/elegant-departure/tree/master/examples/async_std.rs
@@ -253,37 +251,6 @@ pub fn get_shutdown_guard() -> ShutdownGuard {
253251
///
254252
/// This function is usually not required. Typically you would await
255253
/// 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-
/// ```
287254
pub fn wait_for_shutdown_complete() -> impl Future<Output = ()> + Send {
288255
REGISTRY.lock().unwrap().wait_for_shutdown_complete()
289256
}
@@ -313,18 +280,6 @@ pub fn wait_for_shutdown_complete() -> impl Future<Output = ()> + Send {
313280
/// elegant_departure::shutdown().await;
314281
/// }
315282
/// ```
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-
/// ```
328283
pub fn shutdown() -> impl Future<Output = ()> + Send {
329284
REGISTRY.lock().unwrap().shutdown();
330285
REGISTRY.lock().unwrap().wait_for_shutdown_complete()

0 commit comments

Comments
 (0)