Skip to content

Commit dc81c8c

Browse files
committed
Switch to hyper graceful shutdown in test proxy
1 parent ed4836c commit dc81c8c

File tree

4 files changed

+76
-11
lines changed

4 files changed

+76
-11
lines changed

Cargo.lock

Lines changed: 64 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ civet = "0.9"
7979
conduit-hyper = { path = "../../jtgeibel/conduit-hyper" }
8080

8181
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] }
82-
tokio = { git = "https://github.com/tokio-rs/tokio", default-features = false, features = ["tcp"]}
82+
tokio = { version = "0.2.0-alpha.1", default-features = false, features = ["tcp"]}
8383
hyper = { git = "https://github.com/hyperium/hyper" }
8484
ctrlc = { version = "3.0", features = ["termination"] }
8585
indexmap = "1.0.2"

src/bin/server.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use std::{
1111

1212
use civet::Server as CivetServer;
1313
use conduit_hyper::Service;
14-
use futures::executor::block_on;
1514
use jemalloc_ctl;
1615
use reqwest::Client;
1716

@@ -110,7 +109,7 @@ fn main() {
110109
// Block the main thread until the server has shutdown
111110
match server {
112111
Hyper(rt) => {
113-
block_on(rt.shutdown_on_idle());
112+
rt.shutdown_on_idle();
114113
}
115114
Civet(server) => {
116115
let (tx, rx) = channel::<()>();

src/tests/record.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,17 @@ pub fn proxy() -> (String, Bomb) {
111111
};
112112

113113
let record = Arc::new(Mutex::new(record));
114-
let srv = hyper::Server::builder(listener.incoming()).serve(Proxy {
115-
sink: sink2,
116-
record: Arc::clone(&record),
117-
client,
118-
});
114+
let srv = hyper::Server::builder(listener.incoming())
115+
.serve(Proxy {
116+
sink: sink2,
117+
record: Arc::clone(&record),
118+
client,
119+
})
120+
.with_graceful_shutdown(async {
121+
quitrx.await.ok();
122+
});
119123

120-
drop(rt.block_on(future::select(srv, quitrx)));
124+
rt.block_on(srv).ok();
121125

122126
let record = record.lock().unwrap();
123127
match *record {

0 commit comments

Comments
 (0)