From 126bd6b5e477c0b6ce442e2b79a7a76f5f3fb2df Mon Sep 17 00:00:00 2001 From: Josh Comer Date: Wed, 19 May 2021 16:06:50 -0300 Subject: [PATCH 1/3] fix: mis-matched tokio dep --- Cargo.lock | 26 +++++++++++++++++++------- Cargo.toml | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e2ed4c..b94e991 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1184,7 +1184,7 @@ dependencies = [ "structopt", "tempfile", "thiserror", - "tokio 1.6.0", + "tokio 0.2.25", "url", "uuid", "walkdir", @@ -1519,6 +1519,18 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "mio-named-pipes" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" +dependencies = [ + "log", + "mio 0.6.23", + "miow 0.3.7", + "winapi 0.3.9", +] + [[package]] name = "mio-uds" version = "0.6.8" @@ -2632,16 +2644,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" dependencies = [ "bytes 0.5.6", + "fnv", "futures-core", "iovec", "lazy_static", "libc", "memchr", "mio 0.6.23", + "mio-named-pipes", "mio-uds", + "num_cpus", "pin-project-lite 0.1.12", "signal-hook-registry", "slab", + "tokio-macros", "winapi 0.3.9", ] @@ -2652,24 +2668,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd3076b5c8cc18138b8f8814895c11eb4de37114a5d127bafdc5e55798ceef37" dependencies = [ "autocfg", - "bytes 1.0.1", "libc", - "memchr", "mio 0.7.11", - "num_cpus", "once_cell", "parking_lot", "pin-project-lite 0.2.6", "signal-hook-registry", - "tokio-macros", "winapi 0.3.9", ] [[package]] name = "tokio-macros" -version = "1.2.0" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" +checksum = "e44da00bfc73a25f814cd8d7e57a68a5c31b74b3152a0a1d1f590c97ed06265a" dependencies = [ "proc-macro2 1.0.26", "quote 1.0.9", diff --git a/Cargo.toml b/Cargo.toml index 446f207..9904977 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ compression = '0.1' which = '4.0' [dependencies.tokio] -version = '1.1' +version = '0.2' features = ['full'] [dependencies.rusqlite] From a8da88b75d163c72a58e98d820e3625680b10536 Mon Sep 17 00:00:00 2001 From: Josh Comer Date: Wed, 19 May 2021 16:08:06 -0300 Subject: [PATCH 2/3] feat: change timing middleware to async --- src/app/server.rs | 63 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/src/app/server.rs b/src/app/server.rs index 5506d17..67e371c 100644 --- a/src/app/server.rs +++ b/src/app/server.rs @@ -181,46 +181,45 @@ async fn start_server(address: String, port: u16, state: ServerState) -> Result< HttpServer::new(move || { let dd_client = dd_client.clone(); actix_web::App::new() - .wrap(Logger::default()) - .wrap(middleware::Compress::default()) - .app_data(server_state.clone()) .wrap_fn(move |req, srv| { - let dd_client = dd_client.clone(); let start_time = if req.path() != "/ok" { Some(SystemTime::now()) } else { None }; - srv.call(req).map(move |res| { - if let Ok(result) = res { - if let Some(time) = start_time { - if let Ok(duration) = time.elapsed() { - let path = contextualize_path(result.request().path()); - let method = result.request().method().as_str(); - let ms = duration.as_millis(); - let status = result.status(); - debug!( - "Request for {} {} duration: {} status: {}", - method, path, ms, status - ); - - dd_client.time( - CustomMetrics::RequestTime.into(), - Some(vec![ - format!("url:{}", path), - format!("method:{}", method), - format!("status:{}", status.as_str()), - ]), - ms as i64, - ); - } + let dd_client = dd_client.clone(); + let fut = srv.call(req); + + async move { + let res = fut.await?; + if let Some(start) = start_time { + if let Ok(duration) = start.elapsed() { + let path = contextualize_path(res.request().path()); + let method = res.request().method().as_str(); + let ms = duration.as_millis(); + let status = res.status(); + debug!( + "Request for {} {} duration: {} status: {}", + method, path, ms, status + ); + + dd_client.time( + CustomMetrics::RequestTime.into(), + Some(vec![ + format!("url:{}", path), + format!("method:{}", method), + format!("status:{}", status.as_str()), + ]), + ms as i64, + ); } - Ok(result) - } else { - res - } - }) + }; + Ok(res) + } }) + .wrap(Logger::default()) + .wrap(middleware::Compress::default()) + .app_data(server_state.clone()) .service(transform_route_sha_env) .service(transform_branch_head) .service(get_envs) From b413c016a0dec911f2c1cf72799b57d22e553bb7 Mon Sep 17 00:00:00 2001 From: Josh Comer Date: Wed, 19 May 2021 16:09:03 -0300 Subject: [PATCH 3/3] Release 0.12.2 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b94e991..67715ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1150,7 +1150,7 @@ dependencies = [ [[package]] name = "hogan" -version = "0.12.1" +version = "0.12.2" dependencies = [ "actix-rt 2.2.0", "actix-service", diff --git a/Cargo.toml b/Cargo.toml index 9904977..2df71ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ doc = false [package] name = 'hogan' -version = '0.12.1' +version = '0.12.2' authors = [ 'Jonathan Morley ', 'Josh Comer ',