From 8b85fee89dd9673acfba7859af328172f1cd43c3 Mon Sep 17 00:00:00 2001 From: Nahum Shalman Date: Wed, 30 Dec 2020 13:01:39 -0500 Subject: [PATCH 1/4] tokio 1.0 and hyper 0.14 --- dropshot/Cargo.toml | 7 +++++-- dropshot/tests/test_pagination.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dropshot/Cargo.toml b/dropshot/Cargo.toml index cdf2b5472..bd6d9f8d3 100644 --- a/dropshot/Cargo.toml +++ b/dropshot/Cargo.toml @@ -14,7 +14,6 @@ bytes = "0.5.4" futures = "0.3.1" hostname = "0.3.0" http = "0.2.0" -hyper = "0.13.0" indexmap = "1.0.0" openapiv3 = "0.3.0" paste = "1.0.0" @@ -34,6 +33,10 @@ features = [ "serde" ] version = "0.3.0" path = "../dropshot_endpoint" +[dependencies.hyper] +version = "0.14" +features = [ "full" ] + [dependencies.serde] version = "1.0.0" features = [ "derive" ] @@ -43,7 +46,7 @@ version = "2.5.0" features = [ "max_level_trace", "release_max_level_debug" ] [dependencies.tokio] -version = "0.2.0" +version = "1.0" features = [ "full" ] [dependencies.uuid] diff --git a/dropshot/tests/test_pagination.rs b/dropshot/tests/test_pagination.rs index 08634ffb6..45ae2fea1 100644 --- a/dropshot/tests/test_pagination.rs +++ b/dropshot/tests/test_pagination.rs @@ -942,7 +942,7 @@ async fn start_example(path: &str, port: u16) -> ExampleContext { return rv; } - tokio::time::delay_for(Duration::from_millis(500)).await; + tokio::time::sleep(Duration::from_millis(500)).await; } panic!( From e8c4f46fef60cfe1fe5f82073c0321608a9b9334 Mon Sep 17 00:00:00 2001 From: Nahum Shalman Date: Wed, 30 Dec 2020 13:02:10 -0500 Subject: [PATCH 2/4] sed -e 's|hyper::error::Error|hyper::Error|' -i dropshot/src/error.rs dropshot/src/http_util.rs dropshot/src/server.rs dropshot/src/test_util.rs --- dropshot/src/error.rs | 2 +- dropshot/src/http_util.rs | 2 +- dropshot/src/server.rs | 8 ++++---- dropshot/src/test_util.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dropshot/src/error.rs b/dropshot/src/error.rs index d25c3849d..ad0af911a 100644 --- a/dropshot/src/error.rs +++ b/dropshot/src/error.rs @@ -44,7 +44,7 @@ * errors into HttpErrors. */ -use hyper::error::Error as HyperError; +use hyper::Error as HyperError; use serde::Deserialize; use serde::Serialize; diff --git a/dropshot/src/http_util.rs b/dropshot/src/http_util.rs index 38a74337a..932a04723 100644 --- a/dropshot/src/http_util.rs +++ b/dropshot/src/http_util.rs @@ -29,7 +29,7 @@ pub async fn http_read_body( cap: usize, ) -> Result where - T: HttpBody + std::marker::Unpin, + T: HttpBody + std::marker::Unpin, { /* * This looks a lot like the implementation of hyper::body::to_bytes(), but diff --git a/dropshot/src/server.rs b/dropshot/src/server.rs index 94110c4d5..d66bb4907 100644 --- a/dropshot/src/server.rs +++ b/dropshot/src/server.rs @@ -68,7 +68,7 @@ pub struct ServerConfig { */ pub struct HttpServer { app_state: Arc, - server_future: Option>>, + server_future: Option>>, local_addr: SocketAddr, close_channel: Option>, } @@ -96,7 +96,7 @@ impl HttpServer { */ pub fn run( &mut self, - ) -> tokio::task::JoinHandle> { + ) -> tokio::task::JoinHandle> { let future = self.server_future.take().expect("cannot run() more than once"); tokio::spawn(async { future.await }) @@ -104,7 +104,7 @@ impl HttpServer { pub async fn wait_for_shutdown( &mut self, - join_handle: tokio::task::JoinHandle>, + join_handle: tokio::task::JoinHandle>, ) -> Result<(), String> { let join_result = join_handle .await @@ -126,7 +126,7 @@ impl HttpServer { api: ApiDescription, private: Arc, log: &Logger, - ) -> Result { + ) -> Result { /* TODO-cleanup too many Arcs? */ let log_close = log.new(o!()); let app_state = Arc::new(DropshotState { diff --git a/dropshot/src/test_util.rs b/dropshot/src/test_util.rs index 86e1c2d10..527b93486 100644 --- a/dropshot/src/test_util.rs +++ b/dropshot/src/test_util.rs @@ -411,7 +411,7 @@ pub struct TestContext { pub client_testctx: ClientTestContext, pub server: HttpServer, pub log: Logger, - server_task: JoinHandle>, + server_task: JoinHandle>, log_context: Option, } From b2ceeb46ccfd2a233824600c8b24c87f06eb944f Mon Sep 17 00:00:00 2001 From: Nahum Shalman Date: Wed, 30 Dec 2020 13:06:44 -0500 Subject: [PATCH 3/4] update bytes to match hyper --- dropshot/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dropshot/Cargo.toml b/dropshot/Cargo.toml index bd6d9f8d3..99de81a33 100644 --- a/dropshot/Cargo.toml +++ b/dropshot/Cargo.toml @@ -10,7 +10,7 @@ repository = "https://github.com/oxidecomputer/dropshot/" [dependencies] async-trait = "0.1.24" base64 = "0.12.3" -bytes = "0.5.4" +bytes = "1" futures = "0.3.1" hostname = "0.3.0" http = "0.2.0" From 7923acfa32653538fa705ff386b48a39507a555c Mon Sep 17 00:00:00 2001 From: Nahum Shalman Date: Wed, 30 Dec 2020 13:32:00 -0500 Subject: [PATCH 4/4] fix style --- dropshot/src/server.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dropshot/src/server.rs b/dropshot/src/server.rs index d66bb4907..403592639 100644 --- a/dropshot/src/server.rs +++ b/dropshot/src/server.rs @@ -94,9 +94,7 @@ impl HttpServer { * TODO-cleanup is it more accurate to call this start() and say it returns * a Future that resolves when the server is finished? */ - pub fn run( - &mut self, - ) -> tokio::task::JoinHandle> { + pub fn run(&mut self) -> tokio::task::JoinHandle> { let future = self.server_future.take().expect("cannot run() more than once"); tokio::spawn(async { future.await })