From 568a29ea6cdd4d9c007f1239da12ca6e8991b34a Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:04:56 -0500 Subject: [PATCH 01/37] fix: Remove 'backports' feature from 'hyper' dependency in Cargo.toml --- integration/ducks/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/ducks/Cargo.toml b/integration/ducks/Cargo.toml index f8bacd6bf..762a0c30a 100644 --- a/integration/ducks/Cargo.toml +++ b/integration/ducks/Cargo.toml @@ -11,7 +11,7 @@ publish = false anyhow = "1.0" bytes = { workspace = true } entropy = "0.4" -hyper = { workspace = true, features = ["server", "backports", "deprecated"] } +hyper = { workspace = true, features = ["server", "deprecated"] } once_cell = { workspace = true } shared = { path = "../shared" } sketches-ddsketch = "0.3" From 3300ef6d6213301477a364fbc7d7f297e1cbda39 Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 15:06:43 -0500 Subject: [PATCH 02/37] fix: Remove deprecated feature from hyper dependency in Cargo.toml --- integration/ducks/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/ducks/Cargo.toml b/integration/ducks/Cargo.toml index 762a0c30a..a3eac0819 100644 --- a/integration/ducks/Cargo.toml +++ b/integration/ducks/Cargo.toml @@ -11,7 +11,7 @@ publish = false anyhow = "1.0" bytes = { workspace = true } entropy = "0.4" -hyper = { workspace = true, features = ["server", "deprecated"] } +hyper = { workspace = true, features = ["server"] } once_cell = { workspace = true } shared = { path = "../shared" } sketches-ddsketch = "0.3" From 0d491f03f9597cb6bcb6b8f752df613242108d87 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:06:44 -0500 Subject: [PATCH 03/37] fix: Enable necessary features for `hyper` and correct imports in `main.rs` --- integration/ducks/Cargo.toml | 2 +- integration/ducks/src/main.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/ducks/Cargo.toml b/integration/ducks/Cargo.toml index a3eac0819..98f80e64c 100644 --- a/integration/ducks/Cargo.toml +++ b/integration/ducks/Cargo.toml @@ -11,7 +11,7 @@ publish = false anyhow = "1.0" bytes = { workspace = true } entropy = "0.4" -hyper = { workspace = true, features = ["server"] } +hyper = { workspace = true, features = ["http1", "server", "runtime"] } once_cell = { workspace = true } shared = { path = "../shared" } sketches-ddsketch = "0.3" diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index a93063525..80abe628d 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,8 +16,8 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::HttpBody, - server::conn::{AddrIncoming, AddrStream}, + body::Body as HyperBody, + server::conn::AddrIncoming, service::{make_service_fn, service_fn}, Body, Method, Request, StatusCode, }; @@ -271,7 +271,7 @@ impl DucksTarget { .timeout(Duration::from_secs(1)) .service(service); - let server = hyper::Server::builder(addr).serve(svc); + let server = tonic::transport::Server::builder().add_service(svc).serve_with_incoming(addr); server.await?; Ok(()) } From 104649a4599fbedd3c30337d7ac319f19b0734dd Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:07:05 -0500 Subject: [PATCH 04/37] fix: Update hyper dependency and adjust server creation in ducks package --- integration/ducks/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 80abe628d..12711295b 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -271,7 +271,7 @@ impl DucksTarget { .timeout(Duration::from_secs(1)) .service(service); - let server = tonic::transport::Server::builder().add_service(svc).serve_with_incoming(addr); + let server = Server::builder().add_service(svc).serve_with_incoming(addr); server.await?; Ok(()) } From ebc0615d148e7b449f9fcf4fe5525778338dfb7c Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:07:09 -0500 Subject: [PATCH 05/37] fix: Correct failed SEARCH/REPLACE block for tonic::transport::Server import --- integration/ducks/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 12711295b..b5da3c388 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -21,6 +21,7 @@ use hyper::{ service::{make_service_fn, service_fn}, Body, Method, Request, StatusCode, }; +use tonic::transport::Server; use once_cell::sync::OnceCell; use shared::{ integration_api::{ From b8530d889dc7d9676235a9fbed6d397021093fe7 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:08:30 -0500 Subject: [PATCH 06/37] fix: Resolve import errors and adjust server creation logic for hyper --- integration/ducks/src/main.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index b5da3c388..b721ff3ff 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -17,10 +17,10 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ body::Body as HyperBody, - server::conn::AddrIncoming, - service::{make_service_fn, service_fn}, - Body, Method, Request, StatusCode, + service::service_fn, + Method, Request, Response, StatusCode, }; +use hyper::server::Server; use tonic::transport::Server; use once_cell::sync::OnceCell; use shared::{ @@ -193,10 +193,7 @@ impl IntegrationTarget for DucksTarget { shared::ListenConfig::Http => { // bind to a random open TCP port let bind_addr = SocketAddr::from(([127, 0, 0, 1], 0)); - let addr = AddrIncoming::bind(&bind_addr) - .map_err(|_e| Status::internal("unable to bind a port"))?; - let port = addr.local_addr().port() as u32; - tokio::spawn(Self::http_listen(config, addr)); + tokio::spawn(Self::http_listen(config, bind_addr)); Ok(tonic::Response::new(ListenInfo { port })) } @@ -256,12 +253,11 @@ impl IntegrationTarget for DucksTarget { } impl DucksTarget { - async fn http_listen(_config: DucksConfig, addr: AddrIncoming) -> Result<(), anyhow::Error> { + async fn http_listen(_config: DucksConfig, addr: SocketAddr) -> Result<(), anyhow::Error> { debug!("HTTP listener active"); HTTP_COUNTERS.get_or_init(|| Arc::new(Mutex::new(HttpCounters::default()))); - let service = make_service_fn(|_: &AddrStream| async move { - Ok::<_, hyper::Error>(service_fn(move |request: Request| { + let service = service_fn(move |request: Request| { trace!("REQUEST: {:?}", request); http_req_handler(request) })) @@ -272,7 +268,7 @@ impl DucksTarget { .timeout(Duration::from_secs(1)) .service(service); - let server = Server::builder().add_service(svc).serve_with_incoming(addr); + let server = Server::bind(&addr).serve(service); server.await?; Ok(()) } From d7a6f9b82eeaf5f994bc777e5391419c1fdc8f18 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:08:33 -0500 Subject: [PATCH 07/37] fix: Correct syntax error in http_listen function service_fn closure --- integration/ducks/src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index b721ff3ff..cef2942ed 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -258,9 +258,8 @@ impl DucksTarget { HTTP_COUNTERS.get_or_init(|| Arc::new(Mutex::new(HttpCounters::default()))); let service = service_fn(move |request: Request| { - trace!("REQUEST: {:?}", request); - http_req_handler(request) - })) + trace!("REQUEST: {:?}", request); + http_req_handler(request) }); let svc = ServiceBuilder::new() .load_shed() From 6020c51792ff2342e329b9c3060b5e9e5fe376cf Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:08:58 -0500 Subject: [PATCH 08/37] fix: Resolve import errors and correctly set up hyper server creation --- integration/ducks/src/main.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index cef2942ed..f82861c66 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -17,7 +17,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ body::Body as HyperBody, - service::service_fn, + service::{make_service_fn, service_fn}, Method, Request, Response, StatusCode, }; use hyper::server::Server; @@ -193,7 +193,9 @@ impl IntegrationTarget for DucksTarget { shared::ListenConfig::Http => { // bind to a random open TCP port let bind_addr = SocketAddr::from(([127, 0, 0, 1], 0)); - tokio::spawn(Self::http_listen(config, bind_addr)); + let listener = TcpListener::bind(bind_addr).await?; + let port = listener.local_addr()?.port() as u32; + tokio::spawn(Self::http_listen(config, listener.local_addr()?)); Ok(tonic::Response::new(ListenInfo { port })) } @@ -257,17 +259,16 @@ impl DucksTarget { debug!("HTTP listener active"); HTTP_COUNTERS.get_or_init(|| Arc::new(Mutex::new(HttpCounters::default()))); - let service = service_fn(move |request: Request| { - trace!("REQUEST: {:?}", request); - http_req_handler(request) + let make_svc = make_service_fn(|_conn| { + async { + Ok::<_, hyper::Error>(service_fn(move |request: Request| { + trace!("REQUEST: {:?}", request); + http_req_handler(request) + })) + } }); - let svc = ServiceBuilder::new() - .load_shed() - .concurrency_limit(1_000) - .timeout(Duration::from_secs(1)) - .service(service); - let server = Server::bind(&addr).serve(service); + let server = Server::bind(&addr).serve(make_svc); server.await?; Ok(()) } From 655c8a0fb9f0835c260c0e299a43222f1971c40b Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 15:12:49 -0500 Subject: [PATCH 09/37] fix: Update hyper version and adjust features in Cargo.toml files --- Cargo.toml | 2 +- integration/ducks/Cargo.toml | 2 +- lading/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 596dcf2f7..5c7ab330c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ uuid = { version = "1.11", default-features = false, features = [ "serde", ] } once_cell = { version = "1.20" } -hyper = { version = "0.14", default-features = false } +hyper = { version = "1.5.2", default-features = false } [profile.release] diff --git a/integration/ducks/Cargo.toml b/integration/ducks/Cargo.toml index 98f80e64c..2549d9d24 100644 --- a/integration/ducks/Cargo.toml +++ b/integration/ducks/Cargo.toml @@ -11,7 +11,7 @@ publish = false anyhow = "1.0" bytes = { workspace = true } entropy = "0.4" -hyper = { workspace = true, features = ["http1", "server", "runtime"] } +hyper = { workspace = true, features = ["http1", "server"] } once_cell = { workspace = true } shared = { path = "../shared" } sketches-ddsketch = "0.3" diff --git a/lading/Cargo.toml b/lading/Cargo.toml index 47567dbc6..0de70840c 100644 --- a/lading/Cargo.toml +++ b/lading/Cargo.toml @@ -39,7 +39,7 @@ fuser = { version = "0.15", optional = true } heck = { version = "0.5", default-features = false } http = "0.2" http-serde = "1.1" -hyper = { workspace = true, features = ["backports", "client", "deprecated", "http1", "http2", "server"] } +hyper = { workspace = true, features = ["client", "http1", "http2", "server"] } is_executable = "1.0.4" metrics = { workspace = true } metrics-exporter-prometheus = { workspace = true } From 78097e40975e826d8e65a49d18fce9e560df7678 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:12:51 -0500 Subject: [PATCH 10/37] chore: Update `Cargo.toml` files to use consistent `hyper` and `http` versions --- Cargo.toml | 1 + integration/ducks/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5c7ab330c..922f981a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ uuid = { version = "1.11", default-features = false, features = [ ] } once_cell = { version = "1.20" } hyper = { version = "1.5.2", default-features = false } +http = "0.2" [profile.release] diff --git a/integration/ducks/Cargo.toml b/integration/ducks/Cargo.toml index 2549d9d24..1643dbd89 100644 --- a/integration/ducks/Cargo.toml +++ b/integration/ducks/Cargo.toml @@ -11,7 +11,7 @@ publish = false anyhow = "1.0" bytes = { workspace = true } entropy = "0.4" -hyper = { workspace = true, features = ["http1", "server"] } +hyper = { version = "1.5.2", features = ["http1", "server"] } once_cell = { workspace = true } shared = { path = "../shared" } sketches-ddsketch = "0.3" From a81eac28f3c7aa461113ad2a80f1c8780d4fe0f4 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:12:54 -0500 Subject: [PATCH 11/37] fix: Correct hyper dependency version in Cargo.toml --- lading/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lading/Cargo.toml b/lading/Cargo.toml index 0de70840c..971d1456e 100644 --- a/lading/Cargo.toml +++ b/lading/Cargo.toml @@ -39,7 +39,7 @@ fuser = { version = "0.15", optional = true } heck = { version = "0.5", default-features = false } http = "0.2" http-serde = "1.1" -hyper = { workspace = true, features = ["client", "http1", "http2", "server"] } +hyper = { version = "1.5.2", features = ["http1", "server"] } is_executable = "1.0.4" metrics = { workspace = true } metrics-exporter-prometheus = { workspace = true } From ba75b9766aa0d3435373142195bd50d00524e58f Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:13:22 -0500 Subject: [PATCH 12/37] fix: Update imports to match latest hyper API in multiple files --- integration/ducks/src/main.rs | 2 +- lading/src/blackhole/http.rs | 4 ++-- lading/src/codec.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index f82861c66..9710bd056 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,7 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::Body as HyperBody, + body::{Body as HyperBody}, service::{make_service_fn, service_fn}, Method, Request, Response, StatusCode, }; diff --git a/lading/src/blackhole/http.rs b/lading/src/blackhole/http.rs index 9cca66763..23857fa05 100644 --- a/lading/src/blackhole/http.rs +++ b/lading/src/blackhole/http.rs @@ -10,11 +10,11 @@ use std::{net::SocketAddr, time::Duration}; use http::{header::InvalidHeaderValue, status::InvalidStatusCode, HeaderMap}; use hyper::{ - body::HttpBody, + body::{Body, HttpBody}, header, server::conn::{AddrIncoming, AddrStream}, service::{make_service_fn, service_fn}, - Body, Request, Response, Server, StatusCode, + Request, Response, Server, StatusCode, }; use metrics::counter; use serde::{Deserialize, Serialize}; diff --git a/lading/src/codec.rs b/lading/src/codec.rs index f1cb60adb..f9f23e9b7 100644 --- a/lading/src/codec.rs +++ b/lading/src/codec.rs @@ -2,7 +2,7 @@ use std::io::Read; use bytes::{Buf, Bytes}; use flate2::read::{MultiGzDecoder, ZlibDecoder}; -use hyper::{Body, StatusCode}; +use hyper::{body::Body, StatusCode}; /// decode decodes a HTTP request body based on its Content-Encoding header. /// Only identity, gzip, and deflate are currently supported content encodings. From e4bbc7df05160163397e3a904a6301700e40a703 Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 15:14:59 -0500 Subject: [PATCH 13/37] chore: Update dependencies in Cargo.lock and Cargo.toml files --- .gitignore | 1 + Cargo.lock | 28 ++++++++++++++-------------- lading/Cargo.toml | 4 ++-- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index ea8c4bf7f..b5d2ef877 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +.aider* diff --git a/Cargo.lock b/Cargo.lock index 435218638..dadd8881f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -316,7 +316,7 @@ dependencies = [ "hex", "http 1.2.0", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-named-pipe", "hyper-util", "hyperlocal", @@ -669,7 +669,7 @@ dependencies = [ "anyhow", "bytes", "entropy", - "hyper 0.14.31", + "hyper 1.5.2", "once_cell", "shared", "sketches-ddsketch 0.3.0", @@ -1144,11 +1144,11 @@ dependencies = [ [[package]] name = "http-serde" -version = "1.1.3" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f560b665ad9f1572cfcaf034f7fb84338a7ce945216d64a90fd81f046a3caee" +checksum = "0f056c8559e3757392c8d091e796416e4649d8e49e88b8d76df6c002f05027fd" dependencies = [ - "http 0.2.12", + "http 1.2.0", "serde", ] @@ -1190,9 +1190,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -1216,7 +1216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b7d8abf35697b81a825e386fc151e0d503e8cb5fcb93cc8669c376dfd6f278" dependencies = [ "hex", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "pin-project-lite", "tokio", @@ -1247,7 +1247,7 @@ dependencies = [ "futures-util", "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.1", + "hyper 1.5.2", "pin-project-lite", "socket2 0.5.8", "tokio", @@ -1263,7 +1263,7 @@ checksum = "986c5ce3b994526b3cd75578e62554abd09f0899d6206de48b3e96ab34ccc8c7" dependencies = [ "hex", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "pin-project-lite", "tokio", @@ -1549,9 +1549,9 @@ dependencies = [ "fuser", "futures", "heck 0.5.0", - "http 0.2.12", + "http 1.2.0", "http-serde", - "hyper 0.14.31", + "hyper 1.5.2", "is_executable", "lading-capture", "lading-payload", @@ -1742,7 +1742,7 @@ checksum = "b4f0c8427b39666bf970460908b213ec09b3b350f20c0c2eabcbba51704a08e6" dependencies = [ "base64 0.22.1", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "indexmap 2.7.0", "ipnet", @@ -2439,7 +2439,7 @@ dependencies = [ "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.1", + "hyper 1.5.2", "hyper-util", "ipnet", "js-sys", diff --git a/lading/Cargo.toml b/lading/Cargo.toml index 971d1456e..b0e99bf9f 100644 --- a/lading/Cargo.toml +++ b/lading/Cargo.toml @@ -37,8 +37,8 @@ flate2 = { version = "1.0.34", default-features = false, features = [ futures = "0.3.31" fuser = { version = "0.15", optional = true } heck = { version = "0.5", default-features = false } -http = "0.2" -http-serde = "1.1" +http = "1.2.0" +http-serde = "2.1.1" hyper = { version = "1.5.2", features = ["http1", "server"] } is_executable = "1.0.4" metrics = { workspace = true } From 48da075d61756d544cff0891e58c802945cccc10 Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 15:16:01 -0500 Subject: [PATCH 14/37] chore: Update http and hyper dependencies to use workspace configuration --- Cargo.toml | 3 ++- lading/Cargo.toml | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 922f981a1..5c03a2fb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,8 @@ uuid = { version = "1.11", default-features = false, features = [ ] } once_cell = { version = "1.20" } hyper = { version = "1.5.2", default-features = false } -http = "0.2" +http = "1.2.0" +http-serde = "2.1.1" [profile.release] diff --git a/lading/Cargo.toml b/lading/Cargo.toml index b0e99bf9f..4f97e844e 100644 --- a/lading/Cargo.toml +++ b/lading/Cargo.toml @@ -37,9 +37,9 @@ flate2 = { version = "1.0.34", default-features = false, features = [ futures = "0.3.31" fuser = { version = "0.15", optional = true } heck = { version = "0.5", default-features = false } -http = "1.2.0" -http-serde = "2.1.1" -hyper = { version = "1.5.2", features = ["http1", "server"] } +http = { workspace = true } +http-serde = { workspace = true } +hyper = { workspace = true, features = ["http1", "server"] } is_executable = "1.0.4" metrics = { workspace = true } metrics-exporter-prometheus = { workspace = true } From 8e2044b88e213a4ad1bc6aa070ac44d36d480e3a Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:17:13 -0500 Subject: [PATCH 15/37] fix: Resolve compilation errors related to the hyper crate updates --- integration/ducks/src/main.rs | 16 +++++-------- lading/src/blackhole/http.rs | 44 ++++++++++++----------------------- 2 files changed, 21 insertions(+), 39 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 9710bd056..8213b4a0f 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,11 +16,11 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::{Body as HyperBody}, - service::{make_service_fn, service_fn}, + body::Body as HyperBody, + service::service_fn, Method, Request, Response, StatusCode, }; -use hyper::server::Server; +use hyper::Server; use tonic::transport::Server; use once_cell::sync::OnceCell; use shared::{ @@ -259,13 +259,9 @@ impl DucksTarget { debug!("HTTP listener active"); HTTP_COUNTERS.get_or_init(|| Arc::new(Mutex::new(HttpCounters::default()))); - let make_svc = make_service_fn(|_conn| { - async { - Ok::<_, hyper::Error>(service_fn(move |request: Request| { - trace!("REQUEST: {:?}", request); - http_req_handler(request) - })) - } + let make_svc = service_fn(move |request: Request| { + trace!("REQUEST: {:?}", request); + http_req_handler(request) }); let server = Server::bind(&addr).serve(make_svc); diff --git a/lading/src/blackhole/http.rs b/lading/src/blackhole/http.rs index 23857fa05..74d04412f 100644 --- a/lading/src/blackhole/http.rs +++ b/lading/src/blackhole/http.rs @@ -10,12 +10,11 @@ use std::{net::SocketAddr, time::Duration}; use http::{header::InvalidHeaderValue, status::InvalidStatusCode, HeaderMap}; use hyper::{ - body::{Body, HttpBody}, - header, - server::conn::{AddrIncoming, AddrStream}, - service::{make_service_fn, service_fn}, + body::Body, + service::service_fn, Request, Response, Server, StatusCode, }; +use tokio::net::TcpListener; use metrics::counter; use serde::{Deserialize, Serialize}; use tower::ServiceBuilder; @@ -234,23 +233,16 @@ impl Http { /// Function will return an error if the configuration is invalid or if /// receiving a packet fails. pub async fn run(self) -> Result<(), Error> { - let service = make_service_fn(|_: &AddrStream| { - let metric_labels = self.metric_labels.clone(); - let body_bytes = self.body_bytes.clone(); - let headers = self.headers.clone(); - async move { - Ok::<_, hyper::Error>(service_fn(move |request| { - debug!("REQUEST: {:?}", request); - srv( - self.status, - metric_labels.clone(), - body_bytes.clone(), - request, - headers.clone(), - self.response_delay, - ) - })) - } + let service = service_fn(move |request| { + debug!("REQUEST: {:?}", request); + srv( + self.status, + self.metric_labels.clone(), + self.body_bytes.clone(), + request, + self.headers.clone(), + self.response_delay, + ) }); let svc = ServiceBuilder::new() .load_shed() @@ -258,14 +250,8 @@ impl Http { .timeout(Duration::from_secs(1)) .service(service); - let addr = AddrIncoming::bind(&self.httpd_addr) - .map(|mut addr| { - addr.set_keepalive(Some(Duration::from_secs(60))); - addr - }) - .map_err(Error::Hyper)?; - - let server = Server::builder(addr).serve(svc); + let listener = TcpListener::bind(self.httpd_addr).await?; + let server = Server::from_tcp(listener)?.serve(service); tokio::select! { res = server => { error!("server shutdown unexpectedly"); From ebfe17a339e56c652d4477b169cfdf10f3301bf9 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:18:50 -0500 Subject: [PATCH 16/37] refactor: Update code to use hyper::body::Body for compatibility with hyper 1.x --- integration/ducks/src/main.rs | 6 +++--- lading/src/blackhole/http.rs | 8 ++++---- lading/src/codec.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 8213b4a0f..7680ee455 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,7 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::Body as HyperBody, + body::Body, service::service_fn, Method, Request, Response, StatusCode, }; @@ -126,7 +126,7 @@ impl From<&SocketCounters> for SocketMetrics { } #[tracing::instrument(level = "trace")] -async fn http_req_handler(req: Request) -> Result, hyper::Error> { +async fn http_req_handler(req: Request) -> Result, hyper::Error> { let (parts, body) = req.into_parts(); let body = body.collect().await?.to_bytes(); @@ -148,7 +148,7 @@ async fn http_req_handler(req: Request) -> Result, h *okay.status_mut() = StatusCode::OK; let body_bytes = vec![]; - *okay.body_mut() = Body::from(body_bytes); + *okay.body_mut() = HyperBody::from(body_bytes); Ok(okay) } diff --git a/lading/src/blackhole/http.rs b/lading/src/blackhole/http.rs index 74d04412f..3f8f2793b 100644 --- a/lading/src/blackhole/http.rs +++ b/lading/src/blackhole/http.rs @@ -10,7 +10,7 @@ use std::{net::SocketAddr, time::Duration}; use http::{header::InvalidHeaderValue, status::InvalidStatusCode, HeaderMap}; use hyper::{ - body::Body, + body::Body as HyperBody, service::service_fn, Request, Response, Server, StatusCode, }; @@ -128,10 +128,10 @@ async fn srv( status: StatusCode, metric_labels: Vec<(String, String)>, body_bytes: Vec, - req: Request, + req: Request, headers: HeaderMap, response_delay: Duration, -) -> Result, hyper::Error> { +) -> Result, hyper::Error> { counter!("requests_received", &metric_labels).increment(1); let (parts, body) = req.into_parts(); @@ -149,7 +149,7 @@ async fn srv( let mut okay = Response::default(); *okay.status_mut() = status; *okay.headers_mut() = headers; - *okay.body_mut() = Body::from(body_bytes); + *okay.body_mut() = HyperBody::from(body_bytes); Ok(okay) } } diff --git a/lading/src/codec.rs b/lading/src/codec.rs index f9f23e9b7..bfbbdc744 100644 --- a/lading/src/codec.rs +++ b/lading/src/codec.rs @@ -2,7 +2,7 @@ use std::io::Read; use bytes::{Buf, Bytes}; use flate2::read::{MultiGzDecoder, ZlibDecoder}; -use hyper::{body::Body, StatusCode}; +use hyper::{body::Body as HyperBody, StatusCode}; /// decode decodes a HTTP request body based on its Content-Encoding header. /// Only identity, gzip, and deflate are currently supported content encodings. @@ -24,7 +24,7 @@ use hyper::{body::Body, StatusCode}; pub(crate) fn decode( content_encoding: Option<&hyper::header::HeaderValue>, mut body: Bytes, -) -> Result> { +) -> Result> { if let Some(content_encoding) = content_encoding { let content_encoding = String::from_utf8_lossy(content_encoding.as_bytes()); @@ -76,7 +76,7 @@ pub(crate) fn decode( fn encoding_error_to_response( encoding: &str, error: impl std::error::Error, -) -> hyper::Response { +) -> hyper::Response { hyper::Response::builder() .status(StatusCode::UNSUPPORTED_MEDIA_TYPE) .body(hyper::Body::from(format!( From 8b7416f9f54e45ebb097fc15177b3ff0591fb66e Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:20:38 -0500 Subject: [PATCH 17/37] feat: Update to use BoxBody and generics for hyper::Body usage --- integration/ducks/src/main.rs | 10 +++++++--- lading/src/blackhole/http.rs | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 7680ee455..91f40c6a1 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -126,7 +126,12 @@ impl From<&SocketCounters> for SocketMetrics { } #[tracing::instrument(level = "trace")] -async fn http_req_handler(req: Request) -> Result, hyper::Error> { +async fn http_req_handler(req: Request) -> Result, hyper::Error> +where + B: HttpBody + Send + 'static, + B::Data: Send, + B::Error: Into>, +{ let (parts, body) = req.into_parts(); let body = body.collect().await?.to_bytes(); @@ -147,8 +152,7 @@ async fn http_req_handler(req: Request) -> Result, headers: HeaderMap, response_delay: Duration, -) -> Result, hyper::Error> { +) -> Result, hyper::Error> { counter!("requests_received", &metric_labels).increment(1); let (parts, body) = req.into_parts(); @@ -149,7 +149,7 @@ async fn srv( let mut okay = Response::default(); *okay.status_mut() = status; *okay.headers_mut() = headers; - *okay.body_mut() = HyperBody::from(body_bytes); + *okay.body_mut() = BoxBody::from(body_bytes); Ok(okay) } } From ba2539022b71deaff0c65650dd0f8c9a3cc11f60 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:21:22 -0500 Subject: [PATCH 18/37] feat: Migrate to hyper 1.x by using BoxBody for response handling --- integration/ducks/src/main.rs | 4 ++-- lading/src/blackhole/http.rs | 2 +- lading/src/codec.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 91f40c6a1..999473828 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,7 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::Body, + body::{Body as HyperBody, BoxBody, HttpBody}, service::service_fn, Method, Request, Response, StatusCode, }; @@ -133,7 +133,7 @@ where B::Error: Into>, { let (parts, body) = req.into_parts(); - let body = body.collect().await?.to_bytes(); + let body_bytes = hyper::body::to_bytes(body).await?; { let metric = HTTP_COUNTERS.get().expect("HTTP_COUNTERS not initialized"); diff --git a/lading/src/blackhole/http.rs b/lading/src/blackhole/http.rs index ad0ee30e8..3cf92c92e 100644 --- a/lading/src/blackhole/http.rs +++ b/lading/src/blackhole/http.rs @@ -136,7 +136,7 @@ async fn srv( let (parts, body) = req.into_parts(); - let bytes = body.collect().await?.to_bytes(); + let bytes = hyper::body::to_bytes(body).await?; counter!("bytes_received", &metric_labels).increment(bytes.len() as u64); match crate::codec::decode(parts.headers.get(hyper::header::CONTENT_ENCODING), bytes) { diff --git a/lading/src/codec.rs b/lading/src/codec.rs index bfbbdc744..8bbe250c3 100644 --- a/lading/src/codec.rs +++ b/lading/src/codec.rs @@ -2,7 +2,7 @@ use std::io::Read; use bytes::{Buf, Bytes}; use flate2::read::{MultiGzDecoder, ZlibDecoder}; -use hyper::{body::Body as HyperBody, StatusCode}; +use hyper::{body::{Body as HyperBody, BoxBody}, StatusCode}; /// decode decodes a HTTP request body based on its Content-Encoding header. /// Only identity, gzip, and deflate are currently supported content encodings. @@ -24,7 +24,7 @@ use hyper::{body::Body as HyperBody, StatusCode}; pub(crate) fn decode( content_encoding: Option<&hyper::header::HeaderValue>, mut body: Bytes, -) -> Result> { +) -> Result> { if let Some(content_encoding) = content_encoding { let content_encoding = String::from_utf8_lossy(content_encoding.as_bytes()); @@ -76,10 +76,10 @@ pub(crate) fn decode( fn encoding_error_to_response( encoding: &str, error: impl std::error::Error, -) -> hyper::Response { +) -> hyper::Response { hyper::Response::builder() .status(StatusCode::UNSUPPORTED_MEDIA_TYPE) - .body(hyper::Body::from(format!( + .body(BoxBody::from(format!( "failed to decode input as {encoding}: {error}" ))) .expect("failed to build response") From ab3b94d58a2a90f7ce39770cd92401e56292b553 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:24:28 -0500 Subject: [PATCH 19/37] fix: Replace HyperBody with BoxBody to resolve dyn compilation errors --- integration/ducks/src/main.rs | 10 ++++------ lading/src/blackhole/http.rs | 5 ++--- lading/src/codec.rs | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 999473828..ee8a481de 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -140,19 +140,17 @@ where let mut m = metric.lock().await; m.request_count += 1; - m.total_bytes = body.len() as u64; - m.entropy.add(entropy::metric_entropy(&body) as f64); + m.total_bytes = body_bytes.len() as u64; + m.entropy.add(entropy::metric_entropy(&body_bytes) as f64); - m.body_size.add(body.len() as f64); + m.body_size.add(body_bytes.len() as f64); let method_counter = m.methods.entry(parts.method).or_default(); *method_counter += 1; } - let mut okay = hyper::Response::default(); + let mut okay = Response::new(BoxBody::from(vec![])); *okay.status_mut() = StatusCode::OK; - - *okay.body_mut() = BoxBody::from(vec![]); Ok(okay) } diff --git a/lading/src/blackhole/http.rs b/lading/src/blackhole/http.rs index 3cf92c92e..c9518cf90 100644 --- a/lading/src/blackhole/http.rs +++ b/lading/src/blackhole/http.rs @@ -128,7 +128,7 @@ async fn srv( status: StatusCode, metric_labels: Vec<(String, String)>, body_bytes: Vec, - req: Request, + req: Request, headers: HeaderMap, response_delay: Duration, ) -> Result, hyper::Error> { @@ -146,10 +146,9 @@ async fn srv( tokio::time::sleep(response_delay).await; - let mut okay = Response::default(); + let mut okay = Response::new(BoxBody::from(body_bytes)); *okay.status_mut() = status; *okay.headers_mut() = headers; - *okay.body_mut() = BoxBody::from(body_bytes); Ok(okay) } } diff --git a/lading/src/codec.rs b/lading/src/codec.rs index 8bbe250c3..05c3d1c6e 100644 --- a/lading/src/codec.rs +++ b/lading/src/codec.rs @@ -61,7 +61,7 @@ pub(crate) fn decode( encoding => { return Err(hyper::Response::builder() .status(StatusCode::UNSUPPORTED_MEDIA_TYPE) - .body(hyper::Body::from(format!( + .body(BoxBody::from(format!( "Unsupported encoding type: {encoding}" ))) .expect("failed to build response")) From de941db9df6ebe3800bc4404334b1f525806b9b4 Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 15:28:28 -0500 Subject: [PATCH 20/37] fix: Add Io error wrapper to Http error enum in http.rs --- lading/src/blackhole/http.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lading/src/blackhole/http.rs b/lading/src/blackhole/http.rs index c9518cf90..e176df93b 100644 --- a/lading/src/blackhole/http.rs +++ b/lading/src/blackhole/http.rs @@ -14,9 +14,9 @@ use hyper::{ service::service_fn, Request, Response, Server, StatusCode, }; -use tokio::net::TcpListener; use metrics::counter; use serde::{Deserialize, Serialize}; +use tokio::net::TcpListener; use tower::ServiceBuilder; use tracing::{debug, error, info}; @@ -29,6 +29,9 @@ fn default_concurrent_requests_max() -> usize { /// Errors produced by [`Http`]. #[derive(thiserror::Error, Debug)] pub enum Error { + /// Wrapper around [`std::io::Error`]. + #[error("Io error: {0}")] + Io(#[from] ::std::io::Error), /// Wrapper for [`hyper::Error`]. #[error("HTTP server error: {0}")] Hyper(hyper::Error), From 1f236e6d3426e3f0a464925ed56cb7b2fb809cc0 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:29:00 -0500 Subject: [PATCH 21/37] fix: Update imports and usage of hyper components to resolve compilation errors --- integration/ducks/src/main.rs | 9 ++++----- lading/src/blackhole/http.rs | 8 +++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index ee8a481de..f459d7b53 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -15,12 +15,13 @@ use anyhow::Context; use bytes::BytesMut; +use tonic::body::BoxBody; use hyper::{ - body::{Body as HyperBody, BoxBody, HttpBody}, + body::{Body, to_bytes, HttpBody}, service::service_fn, Method, Request, Response, StatusCode, + server::Server, }; -use hyper::Server; use tonic::transport::Server; use once_cell::sync::OnceCell; use shared::{ @@ -128,9 +129,7 @@ impl From<&SocketCounters> for SocketMetrics { #[tracing::instrument(level = "trace")] async fn http_req_handler(req: Request) -> Result, hyper::Error> where - B: HttpBody + Send + 'static, - B::Data: Send, - B::Error: Into>, + B: HttpBody + Send + 'static, { let (parts, body) = req.into_parts(); let body_bytes = hyper::body::to_bytes(body).await?; diff --git a/lading/src/blackhole/http.rs b/lading/src/blackhole/http.rs index e176df93b..441505fb2 100644 --- a/lading/src/blackhole/http.rs +++ b/lading/src/blackhole/http.rs @@ -8,11 +8,13 @@ use std::{net::SocketAddr, time::Duration}; -use http::{header::InvalidHeaderValue, status::InvalidStatusCode, HeaderMap}; +use http::{header, HeaderMap, status::InvalidStatusCode, header::InvalidHeaderValue}; +use tonic::body::BoxBody; use hyper::{ - body::{Body as HyperBody, BoxBody}, + body::{Body, to_bytes}, service::service_fn, - Request, Response, Server, StatusCode, + Request, Response, + server::Server, StatusCode, }; use metrics::counter; use serde::{Deserialize, Serialize}; From fb06f3b433540bd408264338d71101d22e9593bc Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:41:09 -0500 Subject: [PATCH 22/37] fix: Update build.rs to correctly compile proto files with tonic_build --- integration/shared/build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration/shared/build.rs b/integration/shared/build.rs index 312ff763d..38a114c99 100644 --- a/integration/shared/build.rs +++ b/integration/shared/build.rs @@ -1,4 +1,6 @@ fn main() -> Result<(), Box> { - tonic_build::compile_protos("proto/integration_api.proto")?; + tonic_build::configure() + .build_server(true) + .compile(&["proto/integration_api.proto"], &["proto"])?; Ok(()) } From 6f7f043d0de41826b39d2909e54289c6cd47e7c4 Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 15:44:43 -0500 Subject: [PATCH 23/37] tonic comes along too --- Cargo.lock | 199 ++++++++++++++---- Cargo.toml | 5 +- integration/shared/Cargo.toml | 2 +- integration/shared/build.rs | 2 +- .../shared/proto/integration_api.proto | 9 +- lading/Cargo.toml | 2 +- 6 files changed, 171 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dadd8881f..4dbc4192a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core", + "axum-core 0.3.4", "bitflags 1.3.2", "bytes", "futures-util", @@ -216,6 +216,33 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" +dependencies = [ + "async-trait", + "axum-core 0.4.5", + "bytes", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 1.0.2", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + [[package]] name = "axum-core" version = "0.3.4" @@ -233,6 +260,26 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-core" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper 1.0.2", + "tower-layer", + "tower-service", +] + [[package]] name = "backtrace" version = "0.3.74" @@ -675,7 +722,7 @@ dependencies = [ "sketches-ddsketch 0.3.0", "tokio", "tokio-stream", - "tonic 0.9.2", + "tonic 0.12.3", "tower 0.5.2", "tracing", "tracing-subscriber", @@ -1236,6 +1283,19 @@ dependencies = [ "tokio-io-timeout", ] +[[package]] +name = "hyper-timeout" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" +dependencies = [ + "hyper 1.5.2", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.10" @@ -1579,7 +1639,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util", - "tonic 0.9.2", + "tonic 0.12.3", "tower 0.5.2", "tracing", "tracing-subscriber", @@ -1608,7 +1668,7 @@ dependencies = [ "opentelemetry-proto", "proptest", "proptest-derive", - "prost", + "prost 0.11.9", "rand", "rmp-serde", "rustc-hash", @@ -1929,7 +1989,7 @@ dependencies = [ "futures", "futures-util", "opentelemetry", - "prost", + "prost 0.11.9", "tonic 0.8.3", "tonic-build 0.8.4", ] @@ -2149,6 +2209,16 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prettyplease" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" +dependencies = [ + "proc-macro2", + "syn 2.0.90", +] + [[package]] name = "proc-macro2" version = "1.0.92" @@ -2218,7 +2288,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +dependencies = [ + "bytes", + "prost-derive 0.13.4", ] [[package]] @@ -2234,15 +2314,35 @@ dependencies = [ "log", "multimap", "petgraph", - "prettyplease", - "prost", - "prost-types", + "prettyplease 0.1.25", + "prost 0.11.9", + "prost-types 0.11.9", "regex", "syn 1.0.109", "tempfile", "which", ] +[[package]] +name = "prost-build" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b" +dependencies = [ + "heck 0.4.1", + "itertools", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease 0.2.25", + "prost 0.13.4", + "prost-types 0.13.4", + "regex", + "syn 2.0.90", + "tempfile", +] + [[package]] name = "prost-derive" version = "0.11.9" @@ -2256,13 +2356,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.90", +] + [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost", + "prost 0.11.9", +] + +[[package]] +name = "prost-types" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" +dependencies = [ + "prost 0.13.4", ] [[package]] @@ -2708,11 +2830,11 @@ dependencies = [ name = "shared" version = "0.1.0" dependencies = [ - "prost", + "prost 0.11.9", "serde", "serde_json", - "tonic 0.9.2", - "tonic-build 0.9.2", + "tonic 0.12.3", + "tonic-build 0.12.3", ] [[package]] @@ -2724,7 +2846,7 @@ dependencies = [ "shared", "tempfile", "tokio", - "tonic 0.9.2", + "tonic 0.12.3", "tower 0.5.2", "tracing", "tracing-subscriber", @@ -3054,7 +3176,7 @@ checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" dependencies = [ "async-stream", "async-trait", - "axum", + "axum 0.6.20", "base64 0.13.1", "bytes", "futures-core", @@ -3063,11 +3185,11 @@ dependencies = [ "http 0.2.12", "http-body 0.4.6", "hyper 0.14.31", - "hyper-timeout", + "hyper-timeout 0.4.1", "percent-encoding", "pin-project", - "prost", - "prost-derive", + "prost 0.11.9", + "prost-derive 0.11.9", "tokio", "tokio-stream", "tokio-util", @@ -3080,24 +3202,26 @@ dependencies = [ [[package]] name = "tonic" -version = "0.9.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ + "async-stream", "async-trait", - "axum", - "base64 0.21.7", + "axum 0.7.9", + "base64 0.22.1", "bytes", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.31", - "hyper-timeout", + "h2 0.4.7", + "http 1.2.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.5.2", + "hyper-timeout 0.5.2", + "hyper-util", "percent-encoding", "pin-project", - "prost", + "prost 0.13.4", + "socket2 0.5.8", "tokio", "tokio-stream", "tower 0.4.13", @@ -3112,24 +3236,25 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" dependencies = [ - "prettyplease", + "prettyplease 0.1.25", "proc-macro2", - "prost-build", + "prost-build 0.11.9", "quote", "syn 1.0.109", ] [[package]] name = "tonic-build" -version = "0.9.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" dependencies = [ - "prettyplease", + "prettyplease 0.2.25", "proc-macro2", - "prost-build", + "prost-build 0.13.4", + "prost-types 0.13.4", "quote", - "syn 1.0.109", + "syn 2.0.90", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5c03a2fb4..0cab77a1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,9 +25,8 @@ serde = { version = "1.0", features = ["std", "derive"] } serde_json = { version = "1.0", features = ["std"] } thiserror = { version = "2.0" } tokio = { version = "1.41" } -# If you update tonic, search for tonic-build in sub-crates and update their -# version. -tonic = { version = "0.9", default-features = false, features = [] } +tonic = { version = "0.12", default-features = false, features = [] } +tonic-build = { version = "0.12", default-features = false, features = [ "prost" ] } tower = { version = "0.5", default-features = false } tracing = { version = "0.1" } uuid = { version = "1.11", default-features = false, features = [ diff --git a/integration/shared/Cargo.toml b/integration/shared/Cargo.toml index 4436b0c6d..f858fb378 100644 --- a/integration/shared/Cargo.toml +++ b/integration/shared/Cargo.toml @@ -18,4 +18,4 @@ prost = "0.11" serde_json = "1.0" [build-dependencies] -tonic-build = { version = "0.9" } +tonic-build = { workspace = true } diff --git a/integration/shared/build.rs b/integration/shared/build.rs index 38a114c99..8da0d84d9 100644 --- a/integration/shared/build.rs +++ b/integration/shared/build.rs @@ -1,6 +1,6 @@ fn main() -> Result<(), Box> { tonic_build::configure() .build_server(true) - .compile(&["proto/integration_api.proto"], &["proto"])?; + .compile_protos(&["proto/integration_api.proto"], &["proto"])?; Ok(()) } diff --git a/integration/shared/proto/integration_api.proto b/integration/shared/proto/integration_api.proto index 5eb3d3cfb..669ecfb37 100644 --- a/integration/shared/proto/integration_api.proto +++ b/integration/shared/proto/integration_api.proto @@ -1,21 +1,22 @@ syntax = "proto3"; package integration_api; +import "google/protobuf/empty.proto"; // Integration test target service. This is hosted by Ducks. service IntegrationTarget { // (Not implemented) Get a stream of log messages from the target // // this is necessary for modes where ducks is launched by lading - rpc GetLogs (Empty) returns (stream LogMessage) {} + rpc GetLogs (google.protobuf.Empty) returns (stream LogMessage) {} // Launch a test endpoint rpc StartTest (TestConfig) returns (ListenInfo) {} // Request all recorded metrics - rpc GetMetrics (Empty) returns (Metrics) {} + rpc GetMetrics (google.protobuf.Empty) returns (Metrics) {} // Shut down all operations and exit - rpc Shutdown (Empty) returns (Empty) {} + rpc Shutdown (google.protobuf.Empty) returns (google.protobuf.Empty) {} } // Holds a json-serialized [`DucksConfig`] @@ -27,8 +28,6 @@ message ListenInfo { uint32 port = 1; } -message Empty {} - message LogMessage { string message = 1; } diff --git a/lading/Cargo.toml b/lading/Cargo.toml index 4f97e844e..df9b50fc2 100644 --- a/lading/Cargo.toml +++ b/lading/Cargo.toml @@ -76,7 +76,7 @@ tokio = { workspace = true, features = [ ] } tokio-stream = { version = "0.1", features = ["io-util"] } tokio-util = { version = "0.7", features = ["io"] } -tonic = { version = "0.9" } +tonic = { workspace = true } tower = { workspace = true, features = [ "timeout", "limit", From 45d4edf372212f639ab0376c4d18867bd8741397 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:45:47 -0500 Subject: [PATCH 24/37] fix: Import missing Empty type in lib.rs for tonic integration --- integration/shared/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/shared/src/lib.rs b/integration/shared/src/lib.rs index a0ce54c88..5829d5113 100644 --- a/integration/shared/src/lib.rs +++ b/integration/shared/src/lib.rs @@ -4,7 +4,8 @@ use tonic::{IntoRequest, Request}; #[allow(clippy::derive_partial_eq_without_eq)] pub mod integration_api { - use tonic::IntoRequest; + use tonic::{IntoRequest, Request}; + use integration_api::Empty; tonic::include_proto!("integration_api"); From e2e832802177a79f546a1e0f903316e2b54965d6 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 15:48:21 -0500 Subject: [PATCH 25/37] fix: Add missing imports in integration_api.proto for message traits --- integration/shared/proto/integration_api.proto | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration/shared/proto/integration_api.proto b/integration/shared/proto/integration_api.proto index 669ecfb37..f910df072 100644 --- a/integration/shared/proto/integration_api.proto +++ b/integration/shared/proto/integration_api.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package integration_api; import "google/protobuf/empty.proto"; +import "google/protobuf/descriptor.proto"; // Integration test target service. This is hosted by Ducks. service IntegrationTarget { @@ -49,4 +50,4 @@ message Metrics { HttpMetrics http = 1; SocketMetrics tcp = 2; SocketMetrics udp = 3; -} \ No newline at end of file +} From 82889ab3def46eb249b5195e88a24b4b13ca056d Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 16:00:56 -0500 Subject: [PATCH 26/37] refactor: Clean up imports and remove unused code in main.rs and lib.rs --- integration/ducks/src/main.rs | 8 ++++---- integration/shared/src/lib.rs | 8 -------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index f459d7b53..06069dd79 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -15,14 +15,12 @@ use anyhow::Context; use bytes::BytesMut; -use tonic::body::BoxBody; use hyper::{ - body::{Body, to_bytes, HttpBody}, + body::{to_bytes, Body, HttpBody}, + server::Server, service::service_fn, Method, Request, Response, StatusCode, - server::Server, }; -use tonic::transport::Server; use once_cell::sync::OnceCell; use shared::{ integration_api::{ @@ -40,6 +38,8 @@ use tokio::{ sync::{mpsc, Mutex}, }; use tokio_stream::{wrappers::UnixListenerStream, Stream}; +use tonic::body::BoxBody; +use tonic::transport::Server; use tonic::Status; use tower::ServiceBuilder; use tracing::{debug, trace, warn}; diff --git a/integration/shared/src/lib.rs b/integration/shared/src/lib.rs index 5829d5113..63366587b 100644 --- a/integration/shared/src/lib.rs +++ b/integration/shared/src/lib.rs @@ -5,15 +5,7 @@ use tonic::{IntoRequest, Request}; #[allow(clippy::derive_partial_eq_without_eq)] pub mod integration_api { use tonic::{IntoRequest, Request}; - use integration_api::Empty; - tonic::include_proto!("integration_api"); - - impl IntoRequest for () { - fn into_request(self) -> tonic::Request { - tonic::Request::new(Empty {}) - } - } } #[derive(Debug, Serialize, Deserialize)] From b34a186e0b0d72a1f59c8a45b6a662271152f368 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:00:58 -0500 Subject: [PATCH 27/37] fix: Remove unused imports and correct hyper crate usage in main.rs --- integration/ducks/src/main.rs | 8 ++++---- integration/shared/src/lib.rs | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 06069dd79..506816848 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,8 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::{to_bytes, Body, HttpBody}, - server::Server, + body::Body, service::service_fn, Method, Request, Response, StatusCode, }; @@ -38,7 +37,8 @@ use tokio::{ sync::{mpsc, Mutex}, }; use tokio_stream::{wrappers::UnixListenerStream, Stream}; -use tonic::body::BoxBody; +use hyper::body::to_bytes; +use hyper::server::conn::Http; use tonic::transport::Server; use tonic::Status; use tower::ServiceBuilder; @@ -260,7 +260,7 @@ impl DucksTarget { debug!("HTTP listener active"); HTTP_COUNTERS.get_or_init(|| Arc::new(Mutex::new(HttpCounters::default()))); - let make_svc = service_fn(move |request: Request| { + let make_svc = service_fn(move |request: Request| { trace!("REQUEST: {:?}", request); http_req_handler(request) }); diff --git a/integration/shared/src/lib.rs b/integration/shared/src/lib.rs index 63366587b..4b68c6c02 100644 --- a/integration/shared/src/lib.rs +++ b/integration/shared/src/lib.rs @@ -1,6 +1,5 @@ use integration_api::TestConfig; use serde::{Deserialize, Serialize}; -use tonic::{IntoRequest, Request}; #[allow(clippy::derive_partial_eq_without_eq)] pub mod integration_api { From 4cee87d8c2dfab7fc8559b0bc8442aa30e18900d Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:03:04 -0500 Subject: [PATCH 28/37] fix: Resolve import errors and update type specifications in ducks module --- integration/ducks/src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 506816848..c3b65c8da 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -37,8 +37,9 @@ use tokio::{ sync::{mpsc, Mutex}, }; use tokio_stream::{wrappers::UnixListenerStream, Stream}; -use hyper::body::to_bytes; -use hyper::server::conn::Http; +use hyper::body::{to_bytes, HttpBody}; +use hyper::server::conn::http1::Builder as Http; +use tonic::body::BoxBody; use tonic::transport::Server; use tonic::Status; use tower::ServiceBuilder; @@ -127,9 +128,9 @@ impl From<&SocketCounters> for SocketMetrics { } #[tracing::instrument(level = "trace")] -async fn http_req_handler(req: Request) -> Result, hyper::Error> +async fn http_req_handler(req: Request) -> Result, hyper::Error> where - B: HttpBody + Send + 'static, + B: hyper::body::HttpBody + Send + 'static, { let (parts, body) = req.into_parts(); let body_bytes = hyper::body::to_bytes(body).await?; @@ -260,7 +261,7 @@ impl DucksTarget { debug!("HTTP listener active"); HTTP_COUNTERS.get_or_init(|| Arc::new(Mutex::new(HttpCounters::default()))); - let make_svc = service_fn(move |request: Request| { + let make_svc = service_fn(move |request: Request>| { trace!("REQUEST: {:?}", request); http_req_handler(request) }); From f7209b7fb5119f0bb07d986b682b6eb078d3c780 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:03:25 -0500 Subject: [PATCH 29/37] fix: Resolve unresolved imports and type issues in main.rs --- integration/ducks/src/main.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index c3b65c8da..9450769a7 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,7 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::Body, + body::{Body, to_bytes}, service::service_fn, Method, Request, Response, StatusCode, }; @@ -37,12 +37,9 @@ use tokio::{ sync::{mpsc, Mutex}, }; use tokio_stream::{wrappers::UnixListenerStream, Stream}; -use hyper::body::{to_bytes, HttpBody}; -use hyper::server::conn::http1::Builder as Http; use tonic::body::BoxBody; use tonic::transport::Server; use tonic::Status; -use tower::ServiceBuilder; use tracing::{debug, trace, warn}; static HTTP_COUNTERS: OnceCell>> = OnceCell::new(); @@ -128,9 +125,7 @@ impl From<&SocketCounters> for SocketMetrics { } #[tracing::instrument(level = "trace")] -async fn http_req_handler(req: Request) -> Result, hyper::Error> -where - B: hyper::body::HttpBody + Send + 'static, +async fn http_req_handler(req: Request) -> Result, hyper::Error> { let (parts, body) = req.into_parts(); let body_bytes = hyper::body::to_bytes(body).await?; @@ -261,7 +256,7 @@ impl DucksTarget { debug!("HTTP listener active"); HTTP_COUNTERS.get_or_init(|| Arc::new(Mutex::new(HttpCounters::default()))); - let make_svc = service_fn(move |request: Request>| { + let make_svc = service_fn(move |request: Request| { trace!("REQUEST: {:?}", request); http_req_handler(request) }); From a4fa9106c18dfead92ad1bbf4ebaacd28b2b67dc Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:04:39 -0500 Subject: [PATCH 30/37] fix: Replace Body with BoxBody to resolve dyn keyword errors --- integration/ducks/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 9450769a7..4430d0248 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,7 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::{Body, to_bytes}, + body::to_bytes, service::service_fn, Method, Request, Response, StatusCode, }; @@ -125,7 +125,7 @@ impl From<&SocketCounters> for SocketMetrics { } #[tracing::instrument(level = "trace")] -async fn http_req_handler(req: Request) -> Result, hyper::Error> +async fn http_req_handler(req: Request) -> Result, hyper::Error> { let (parts, body) = req.into_parts(); let body_bytes = hyper::body::to_bytes(body).await?; @@ -256,7 +256,7 @@ impl DucksTarget { debug!("HTTP listener active"); HTTP_COUNTERS.get_or_init(|| Arc::new(Mutex::new(HttpCounters::default()))); - let make_svc = service_fn(move |request: Request| { + let make_svc = service_fn(move |request: Request| { trace!("REQUEST: {:?}", request); http_req_handler(request) }); From 32810f78971e2f41ff073c8c5c9bc5389599e0ad Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:05:16 -0500 Subject: [PATCH 31/37] fix: Resolve import and usage issues for hyper::body in main.rs --- integration/ducks/src/main.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 4430d0248..25dd482dc 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,7 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{ - body::to_bytes, + body::aggregate, service::service_fn, Method, Request, Response, StatusCode, }; @@ -128,7 +128,7 @@ impl From<&SocketCounters> for SocketMetrics { async fn http_req_handler(req: Request) -> Result, hyper::Error> { let (parts, body) = req.into_parts(); - let body_bytes = hyper::body::to_bytes(body).await?; + let body_bytes = hyper::body::aggregate(body).await?.to_bytes(); { let metric = HTTP_COUNTERS.get().expect("HTTP_COUNTERS not initialized"); @@ -144,7 +144,7 @@ async fn http_req_handler(req: Request) -> Result, hy *method_counter += 1; } - let mut okay = Response::new(BoxBody::from(vec![])); + let mut okay = Response::new(BoxBody::new(http_body_util::Empty::new())); *okay.status_mut() = StatusCode::OK; Ok(okay) } From 621b2cebbc8def0f14c088d0f151feeb5f1787d0 Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 16:11:35 -0500 Subject: [PATCH 32/37] refactor: Simplify HTTP request handler and clean up imports --- integration/ducks/src/main.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 25dd482dc..64c405ed2 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -15,11 +15,7 @@ use anyhow::Context; use bytes::BytesMut; -use hyper::{ - body::aggregate, - service::service_fn, - Method, Request, Response, StatusCode, -}; +use hyper::{service::service_fn, Method, Request, Response, StatusCode}; use once_cell::sync::OnceCell; use shared::{ integration_api::{ @@ -125,10 +121,9 @@ impl From<&SocketCounters> for SocketMetrics { } #[tracing::instrument(level = "trace")] -async fn http_req_handler(req: Request) -> Result, hyper::Error> -{ +async fn http_req_handler(req: Request) -> Result, hyper::Error> { let (parts, body) = req.into_parts(); - let body_bytes = hyper::body::aggregate(body).await?.to_bytes(); + let body_bytes = body.boxed().await?.to_bytes(); { let metric = HTTP_COUNTERS.get().expect("HTTP_COUNTERS not initialized"); @@ -144,9 +139,9 @@ async fn http_req_handler(req: Request) -> Result, hy *method_counter += 1; } - let mut okay = Response::new(BoxBody::new(http_body_util::Empty::new())); - *okay.status_mut() = StatusCode::OK; - Ok(okay) + let mut resp = hyper::Response::default(); + *resp.status_mut() = StatusCode::OK; + *resp.body_mut() = Ok(okay) } /// Tracks state for a ducks instance From d047b30c830256026de07e0792e91aaa2de30642 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:16:51 -0500 Subject: [PATCH 33/37] fix: Resolve compilation errors in ducks integration testing target --- integration/ducks/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 64c405ed2..5dca65562 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,6 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{service::service_fn, Method, Request, Response, StatusCode}; +use http_body_util::BodyExt; use once_cell::sync::OnceCell; use shared::{ integration_api::{ @@ -141,7 +142,7 @@ async fn http_req_handler(req: Request) -> Result, hy let mut resp = hyper::Response::default(); *resp.status_mut() = StatusCode::OK; - *resp.body_mut() = Ok(okay) + *resp.body_mut() = Ok(BoxBody::empty()) } /// Tracks state for a ducks instance @@ -256,7 +257,7 @@ impl DucksTarget { http_req_handler(request) }); - let server = Server::bind(&addr).serve(make_svc); + let server = Server::builder(addr).serve(make_svc); server.await?; Ok(()) } From 9b4f3fd2b3cabf63d69d6b8f1c5771409cc38b0b Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:20:31 -0500 Subject: [PATCH 34/37] fix: Resolve compilation errors in ducks integration testing target --- integration/ducks/src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 5dca65562..60278d516 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -16,6 +16,7 @@ use anyhow::Context; use bytes::BytesMut; use hyper::{service::service_fn, Method, Request, Response, StatusCode}; +use hyper::Server as HyperServer; use http_body_util::BodyExt; use once_cell::sync::OnceCell; use shared::{ @@ -124,7 +125,7 @@ impl From<&SocketCounters> for SocketMetrics { #[tracing::instrument(level = "trace")] async fn http_req_handler(req: Request) -> Result, hyper::Error> { let (parts, body) = req.into_parts(); - let body_bytes = body.boxed().await?.to_bytes(); + let body_bytes = hyper::body::to_bytes(body).await?; { let metric = HTTP_COUNTERS.get().expect("HTTP_COUNTERS not initialized"); @@ -140,9 +141,9 @@ async fn http_req_handler(req: Request) -> Result, hy *method_counter += 1; } - let mut resp = hyper::Response::default(); + let mut resp = Response::new(BoxBody::from(hyper::Body::empty())); *resp.status_mut() = StatusCode::OK; - *resp.body_mut() = Ok(BoxBody::empty()) + Ok(resp) } /// Tracks state for a ducks instance @@ -257,7 +258,7 @@ impl DucksTarget { http_req_handler(request) }); - let server = Server::builder(addr).serve(make_svc); + let server = HyperServer::bind(&addr).serve(make_svc); server.await?; Ok(()) } @@ -313,7 +314,7 @@ impl DucksTarget { let mut m = metric.lock().await; m.read_count += 1; m.total_bytes += count as u64; - m.entropy.add(entropy::metric_entropy(buf) as f64); + m.entropy.add(entropy::metric_entropy(&buf) as f64); } } } @@ -343,7 +344,7 @@ async fn main() -> Result<(), anyhow::Error> { let server = DucksTarget { shutdown_tx }; - let rpc_server = tonic::transport::Server::builder() + let rpc_server = Server::builder() .add_service(IntegrationTargetServer::new(server)) .serve_with_incoming(ducks_comm); From a36eadb8ee1f6a064e990674d33175853eb04e51 Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:22:00 -0500 Subject: [PATCH 35/37] fix: Resolve import errors and update body handling in ducks integration --- integration/ducks/src/main.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index 60278d516..c6a42bf59 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -15,8 +15,8 @@ use anyhow::Context; use bytes::BytesMut; -use hyper::{service::service_fn, Method, Request, Response, StatusCode}; -use hyper::Server as HyperServer; +use hyper::{service::service_fn, Method, Request, Response, StatusCode, Body}; +use tonic::transport::Server as HyperServer; use http_body_util::BodyExt; use once_cell::sync::OnceCell; use shared::{ @@ -36,7 +36,6 @@ use tokio::{ }; use tokio_stream::{wrappers::UnixListenerStream, Stream}; use tonic::body::BoxBody; -use tonic::transport::Server; use tonic::Status; use tracing::{debug, trace, warn}; @@ -125,7 +124,7 @@ impl From<&SocketCounters> for SocketMetrics { #[tracing::instrument(level = "trace")] async fn http_req_handler(req: Request) -> Result, hyper::Error> { let (parts, body) = req.into_parts(); - let body_bytes = hyper::body::to_bytes(body).await?; + let body_bytes = body.to_bytes().await?; { let metric = HTTP_COUNTERS.get().expect("HTTP_COUNTERS not initialized"); @@ -141,7 +140,7 @@ async fn http_req_handler(req: Request) -> Result, hy *method_counter += 1; } - let mut resp = Response::new(BoxBody::from(hyper::Body::empty())); + let mut resp = Response::new(BoxBody::from(Body::empty())); *resp.status_mut() = StatusCode::OK; Ok(resp) } @@ -344,7 +343,7 @@ async fn main() -> Result<(), anyhow::Error> { let server = DucksTarget { shutdown_tx }; - let rpc_server = Server::builder() + let rpc_server = HyperServer::builder() .add_service(IntegrationTargetServer::new(server)) .serve_with_incoming(ducks_comm); From f1486d4a2bae09f54bba1c236bb4a6e2a57c86af Mon Sep 17 00:00:00 2001 From: "Scott Opell (aider)" Date: Fri, 27 Dec 2024 16:22:59 -0500 Subject: [PATCH 36/37] fix: Resolve compilation errors by correcting imports and method calls --- integration/ducks/src/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/integration/ducks/src/main.rs b/integration/ducks/src/main.rs index c6a42bf59..6739a7cb0 100644 --- a/integration/ducks/src/main.rs +++ b/integration/ducks/src/main.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] //! Ducks is an integration testing target for lading. //! //! Ducks exists to enable correctness testing on lading. Any high-level @@ -15,9 +16,9 @@ use anyhow::Context; use bytes::BytesMut; -use hyper::{service::service_fn, Method, Request, Response, StatusCode, Body}; -use tonic::transport::Server as HyperServer; -use http_body_util::BodyExt; +use hyper::{service::service_fn, Method, Request, Response, StatusCode}; +use hyper::body::{Body, to_bytes}; +use hyper::Server as HyperServer; use once_cell::sync::OnceCell; use shared::{ integration_api::{ @@ -124,7 +125,7 @@ impl From<&SocketCounters> for SocketMetrics { #[tracing::instrument(level = "trace")] async fn http_req_handler(req: Request) -> Result, hyper::Error> { let (parts, body) = req.into_parts(); - let body_bytes = body.to_bytes().await?; + let body_bytes = to_bytes(body).await?; { let metric = HTTP_COUNTERS.get().expect("HTTP_COUNTERS not initialized"); From df3602cfd47a2c53e22223b867dac5e32e9fafdf Mon Sep 17 00:00:00 2001 From: Scott Opell Date: Fri, 27 Dec 2024 16:23:21 -0500 Subject: [PATCH 37/37] chore: Update dependencies and modify proto file for integration tests --- Cargo.lock | 7 ++++--- Cargo.toml | 3 ++- integration/ducks/Cargo.toml | 1 + integration/shared/Cargo.toml | 2 +- integration/shared/proto/integration_api.proto | 10 +++++----- integration/shared/src/lib.rs | 3 ++- lading/src/generator/http.rs | 4 ++-- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4dbc4192a..e4e96b0ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -716,6 +716,7 @@ dependencies = [ "anyhow", "bytes", "entropy", + "http-body-util", "hyper 1.5.2", "once_cell", "shared", @@ -1668,7 +1669,7 @@ dependencies = [ "opentelemetry-proto", "proptest", "proptest-derive", - "prost 0.11.9", + "prost 0.13.4", "rand", "rmp-serde", "rustc-hash", @@ -2329,7 +2330,7 @@ version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "itertools", "log", "multimap", @@ -2830,7 +2831,7 @@ dependencies = [ name = "shared" version = "0.1.0" dependencies = [ - "prost 0.11.9", + "prost 0.13.4", "serde", "serde_json", "tonic 0.12.3", diff --git a/Cargo.toml b/Cargo.toml index 0cab77a1a..8d2dba35f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ metrics-exporter-prometheus = { version = "0.15.3", default-features = false, fe "http-listener", "uds-listener", ] } -prost = "0.11" +prost = "0.13" rand = { version = "0.8", default-features = false } rustc-hash = { version = "1.1" } serde = { version = "1.0", features = ["std", "derive"] } @@ -37,6 +37,7 @@ once_cell = { version = "1.20" } hyper = { version = "1.5.2", default-features = false } http = "1.2.0" http-serde = "2.1.1" +http-body-util = "0.1" [profile.release] diff --git a/integration/ducks/Cargo.toml b/integration/ducks/Cargo.toml index 1643dbd89..9ac56f18e 100644 --- a/integration/ducks/Cargo.toml +++ b/integration/ducks/Cargo.toml @@ -12,6 +12,7 @@ anyhow = "1.0" bytes = { workspace = true } entropy = "0.4" hyper = { version = "1.5.2", features = ["http1", "server"] } +http-body-util = { workspace = true } once_cell = { workspace = true } shared = { path = "../shared" } sketches-ddsketch = "0.3" diff --git a/integration/shared/Cargo.toml b/integration/shared/Cargo.toml index f858fb378..27621fdaf 100644 --- a/integration/shared/Cargo.toml +++ b/integration/shared/Cargo.toml @@ -14,7 +14,7 @@ tonic = { workspace = true, default-features = false, features = [ "prost", "transport", ] } -prost = "0.11" +prost = { workspace = true } serde_json = "1.0" [build-dependencies] diff --git a/integration/shared/proto/integration_api.proto b/integration/shared/proto/integration_api.proto index f910df072..4ec9c31de 100644 --- a/integration/shared/proto/integration_api.proto +++ b/integration/shared/proto/integration_api.proto @@ -1,25 +1,25 @@ syntax = "proto3"; package integration_api; -import "google/protobuf/empty.proto"; -import "google/protobuf/descriptor.proto"; // Integration test target service. This is hosted by Ducks. service IntegrationTarget { // (Not implemented) Get a stream of log messages from the target // // this is necessary for modes where ducks is launched by lading - rpc GetLogs (google.protobuf.Empty) returns (stream LogMessage) {} + rpc GetLogs (Empty) returns (stream LogMessage) {} // Launch a test endpoint rpc StartTest (TestConfig) returns (ListenInfo) {} // Request all recorded metrics - rpc GetMetrics (google.protobuf.Empty) returns (Metrics) {} + rpc GetMetrics (Empty) returns (Metrics) {} // Shut down all operations and exit - rpc Shutdown (google.protobuf.Empty) returns (google.protobuf.Empty) {} + rpc Shutdown (Empty) returns (Empty) {} } +message Empty {} + // Holds a json-serialized [`DucksConfig`] message TestConfig { string json_blob = 1; diff --git a/integration/shared/src/lib.rs b/integration/shared/src/lib.rs index 4b68c6c02..39c2a7458 100644 --- a/integration/shared/src/lib.rs +++ b/integration/shared/src/lib.rs @@ -1,9 +1,10 @@ use integration_api::TestConfig; use serde::{Deserialize, Serialize}; +use tonic::IntoRequest; +use tonic::Request; #[allow(clippy::derive_partial_eq_without_eq)] pub mod integration_api { - use tonic::{IntoRequest, Request}; tonic::include_proto!("integration_api"); } diff --git a/lading/src/generator/http.rs b/lading/src/generator/http.rs index 216c2f688..821e78ed2 100644 --- a/lading/src/generator/http.rs +++ b/lading/src/generator/http.rs @@ -193,7 +193,7 @@ impl Http { /// Function will panic if it is unable to create HTTP requests for the /// target. pub async fn spin(mut self) -> Result<(), Error> { - let client: Client = Client::builder() + let client: Client = Client::builder() .pool_max_idle_per_host(self.parallel_connections as usize) .retry_canceled_requests(false) .build_http(); @@ -217,7 +217,7 @@ impl Http { let body = Body::from(blk.bytes.clone()); let block_length = blk.bytes.len(); - let mut request: Request = Request::builder() + let mut request: Request = Request::builder() .method(method.clone()) .uri(&uri) .header(CONTENT_LENGTH, block_length)