From 603b3933023efbff2f1d91146d1d0fbd6961fb57 Mon Sep 17 00:00:00 2001 From: Rostislav Rumenov Date: Mon, 4 Nov 2024 09:32:18 +0000 Subject: [PATCH 1/3] . --- Cargo.Bazel.Fuzzing.json.lock | 7 +--- Cargo.Bazel.Fuzzing.toml.lock | 1 - Cargo.Bazel.json.lock | 7 +--- Cargo.Bazel.toml.lock | 1 - Cargo.toml | 1 - bazel/external_crates.bzl | 3 -- rs/async_utils/BUILD.bazel | 2 - rs/async_utils/Cargo.toml | 2 - rs/async_utils/src/axum.rs | 42 ------------------- rs/async_utils/src/lib.rs | 1 - .../systemd_journal_gatewayd_shim/BUILD.bazel | 1 - .../systemd_journal_gatewayd_shim/Cargo.toml | 1 - .../systemd_journal_gatewayd_shim/src/api.rs | 3 +- .../nns_tests/registry_authentication_test.rs | 3 +- 14 files changed, 4 insertions(+), 71 deletions(-) delete mode 100644 rs/async_utils/src/axum.rs diff --git a/Cargo.Bazel.Fuzzing.json.lock b/Cargo.Bazel.Fuzzing.json.lock index f2ebe56cbba..4eb97056acf 100644 --- a/Cargo.Bazel.Fuzzing.json.lock +++ b/Cargo.Bazel.Fuzzing.json.lock @@ -1,5 +1,5 @@ { - "checksum": "7661b2c9fdc930e58622dc8df6307c9e805eb95556ad2b11b93ca0561235524a", + "checksum": "a944774f76fd863addc246ea846e7ce2d528289902b32e913abf021c2dabadc1", "crates": { "abnf 0.12.0": { "name": "abnf", @@ -19326,10 +19326,6 @@ "id": "syn 1.0.109", "target": "syn" }, - { - "id": "sync_wrapper 1.0.1", - "target": "sync_wrapper" - }, { "id": "tar 0.4.39", "target": "tar" @@ -85566,7 +85562,6 @@ "stubborn-io 0.3.2", "subtle 2.6.1", "syn 1.0.109", - "sync_wrapper 1.0.1", "tar 0.4.39", "tarpc 0.34.0", "tempfile 3.12.0", diff --git a/Cargo.Bazel.Fuzzing.toml.lock b/Cargo.Bazel.Fuzzing.toml.lock index 595374b648c..860dcd400b7 100644 --- a/Cargo.Bazel.Fuzzing.toml.lock +++ b/Cargo.Bazel.Fuzzing.toml.lock @@ -3244,7 +3244,6 @@ dependencies = [ "stubborn-io", "subtle", "syn 1.0.109", - "sync_wrapper 1.0.1", "tar", "tarpc", "tempfile", diff --git a/Cargo.Bazel.json.lock b/Cargo.Bazel.json.lock index 8c2d44e04aa..d3da8379dd2 100644 --- a/Cargo.Bazel.json.lock +++ b/Cargo.Bazel.json.lock @@ -1,5 +1,5 @@ { - "checksum": "d4b611a5f338012769866b27437875353f5d76dbabb9b135418806599a3b8912", + "checksum": "a21d4243de1c16fbbeea6a2220ad62857326adde7983b85ed3109386d7f30362", "crates": { "abnf 0.12.0": { "name": "abnf", @@ -19149,10 +19149,6 @@ "id": "syn 1.0.109", "target": "syn" }, - { - "id": "sync_wrapper 1.0.1", - "target": "sync_wrapper" - }, { "id": "tar 0.4.39", "target": "tar" @@ -85439,7 +85435,6 @@ "stubborn-io 0.3.2", "subtle 2.6.1", "syn 1.0.109", - "sync_wrapper 1.0.1", "tar 0.4.39", "tarpc 0.34.0", "tempfile 3.12.0", diff --git a/Cargo.Bazel.toml.lock b/Cargo.Bazel.toml.lock index 7aee9c1106d..d38c3b8835a 100644 --- a/Cargo.Bazel.toml.lock +++ b/Cargo.Bazel.toml.lock @@ -3233,7 +3233,6 @@ dependencies = [ "stubborn-io", "subtle", "syn 1.0.109", - "sync_wrapper 1.0.1", "tar", "tarpc", "tempfile", diff --git a/Cargo.toml b/Cargo.toml index 67206e66325..1f5075b6085 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -689,7 +689,6 @@ strum = { version = "0.26.3", features = ["derive"] } strum_macros = "0.26.4" subtle = "2.6.1" syn = { version = "1.0.109", features = ["fold", "full"] } -sync_wrapper = "1.0.1" tar = "0.4.39" tempfile = "3.12.0" thiserror = "1.0.62" diff --git a/bazel/external_crates.bzl b/bazel/external_crates.bzl index b8012832eb0..252c63a1f81 100644 --- a/bazel/external_crates.bzl +++ b/bazel/external_crates.bzl @@ -1196,9 +1196,6 @@ def external_crates_repository(name, cargo_lockfile, lockfile, sanitizers_enable "full", ], ), - "sync_wrapper": crate.spec( - version = "^1.0.1", - ), "tar": crate.spec( version = "^0.4.38", ), diff --git a/rs/async_utils/BUILD.bazel b/rs/async_utils/BUILD.bazel index ff581b82ac8..a9e053e0e7a 100644 --- a/rs/async_utils/BUILD.bazel +++ b/rs/async_utils/BUILD.bazel @@ -11,14 +11,12 @@ rust_library( # Keep sorted. "@crate_index//:anyhow", "@crate_index//:async-stream", - "@crate_index//:axum", "@crate_index//:byte-unit", "@crate_index//:bytes", "@crate_index//:futures", "@crate_index//:futures-util", "@crate_index//:hyper", "@crate_index//:slog", - "@crate_index//:sync_wrapper", "@crate_index//:thiserror", "@crate_index//:tokio", "@crate_index//:tonic", diff --git a/rs/async_utils/Cargo.toml b/rs/async_utils/Cargo.toml index 658a667f022..fd56035507e 100644 --- a/rs/async_utils/Cargo.toml +++ b/rs/async_utils/Cargo.toml @@ -9,14 +9,12 @@ documentation.workspace = true [dependencies] anyhow = { workspace = true } async-stream = { workspace = true } -axum = { workspace = true } byte-unit = "4.0.14" bytes = { workspace = true } futures = { workspace = true } futures-util = { workspace = true } hyper = { workspace = true } slog = { workspace = true } -sync_wrapper = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true } tonic = { workspace = true } diff --git a/rs/async_utils/src/axum.rs b/rs/async_utils/src/axum.rs deleted file mode 100644 index 2a39243bb67..00000000000 --- a/rs/async_utils/src/axum.rs +++ /dev/null @@ -1,42 +0,0 @@ -use axum::body::{Body, HttpBody}; -use bytes::Bytes; -use futures_util::Stream; -use std::{ - pin::{pin, Pin}, - task::Poll, -}; -use sync_wrapper::SyncWrapper; - -/// Wrapper used for conversion from an Axum Body to a Reqwest one -pub struct BodyDataStream { - inner: SyncWrapper, -} - -impl BodyDataStream { - pub const fn new(body: Body) -> Self { - Self { - inner: SyncWrapper::new(body), - } - } -} - -impl Stream for BodyDataStream { - type Item = Result; - - #[inline] - fn poll_next( - mut self: Pin<&mut Self>, - cx: &mut core::task::Context<'_>, - ) -> Poll> { - loop { - let mut pinned = pin!(self.inner.get_mut()); - match futures_util::ready!(pinned.as_mut().poll_frame(cx)?) { - Some(frame) => match frame.into_data() { - Ok(data) => return Poll::Ready(Some(Ok(data))), - Err(_frame) => {} - }, - None => return Poll::Ready(None), - } - } - } -} diff --git a/rs/async_utils/src/lib.rs b/rs/async_utils/src/lib.rs index 366dbb7dc25..30ab8bda963 100644 --- a/rs/async_utils/src/lib.rs +++ b/rs/async_utils/src/lib.rs @@ -1,6 +1,5 @@ use slog::{info, Logger}; -pub mod axum; mod hyper; mod join_map; mod unix; diff --git a/rs/boundary_node/systemd_journal_gatewayd_shim/BUILD.bazel b/rs/boundary_node/systemd_journal_gatewayd_shim/BUILD.bazel index 2112c729dc9..16e571a749b 100644 --- a/rs/boundary_node/systemd_journal_gatewayd_shim/BUILD.bazel +++ b/rs/boundary_node/systemd_journal_gatewayd_shim/BUILD.bazel @@ -2,7 +2,6 @@ load("@rules_rust//rust:defs.bzl", "rust_binary") DEPENDENCIES = [ # Keep sorted. - "//rs/async_utils", "@crate_index//:anyhow", "@crate_index//:axum", "@crate_index//:clap", diff --git a/rs/boundary_node/systemd_journal_gatewayd_shim/Cargo.toml b/rs/boundary_node/systemd_journal_gatewayd_shim/Cargo.toml index 9640d0e3c46..d41c3ff976a 100644 --- a/rs/boundary_node/systemd_journal_gatewayd_shim/Cargo.toml +++ b/rs/boundary_node/systemd_journal_gatewayd_shim/Cargo.toml @@ -12,7 +12,6 @@ async-trait = { workspace = true } axum = { workspace = true } clap = { workspace = true } http = { workspace = true } -ic-async-utils = { path = "../../async_utils" } itertools = { workspace = true } reqwest = { workspace = true } thiserror = { workspace = true } diff --git a/rs/boundary_node/systemd_journal_gatewayd_shim/src/api.rs b/rs/boundary_node/systemd_journal_gatewayd_shim/src/api.rs index da5896f149c..c27c7e73185 100644 --- a/rs/boundary_node/systemd_journal_gatewayd_shim/src/api.rs +++ b/rs/boundary_node/systemd_journal_gatewayd_shim/src/api.rs @@ -7,7 +7,6 @@ use axum::{ http::StatusCode, response::{IntoResponse, Response}, }; -use ic_async_utils::axum::BodyDataStream; use itertools::{concat, Itertools}; use reqwest::Method; use url::Url; @@ -93,7 +92,7 @@ pub(crate) async fn entries( }); let (parts, body) = req.into_parts(); - let body_stream = BodyDataStream::new(body); + let body_stream = body.into_data_stream(); let mut upstream_req = reqwest::Request::new(Method::GET, u); diff --git a/rs/tests/src/nns_tests/registry_authentication_test.rs b/rs/tests/src/nns_tests/registry_authentication_test.rs index fd6fbcbc358..e3ecf86fa9e 100644 --- a/rs/tests/src/nns_tests/registry_authentication_test.rs +++ b/rs/tests/src/nns_tests/registry_authentication_test.rs @@ -20,7 +20,6 @@ use axum::{ extract::{Request, State}, routing::any, }; -use ic_async_utils::axum::BodyDataStream; use ic_crypto_utils_threshold_sig_der::threshold_sig_public_key_from_der; use ic_nns_test_utils::itest_helpers::{ forward_call_via_universal_canister, set_up_universal_canister, @@ -188,7 +187,7 @@ async fn mitm_service( let (parts, body) = req.into_parts(); *request.headers_mut() = parts.headers; - *request.body_mut() = Some(reqwest::Body::wrap_stream(BodyDataStream::new(body))); + *request.body_mut() = Some(reqwest::Body::wrap_stream(body.into_data_stream())); let response = client .execute(request) From 01db0d838bf435a992cff425ed5a7aff2f75263a Mon Sep 17 00:00:00 2001 From: Rostislav Rumenov Date: Mon, 4 Nov 2024 09:33:37 +0000 Subject: [PATCH 2/3] . --- rs/async_utils/BUILD.bazel | 1 - rs/async_utils/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/rs/async_utils/BUILD.bazel b/rs/async_utils/BUILD.bazel index a9e053e0e7a..41ab87702fa 100644 --- a/rs/async_utils/BUILD.bazel +++ b/rs/async_utils/BUILD.bazel @@ -17,7 +17,6 @@ rust_library( "@crate_index//:futures-util", "@crate_index//:hyper", "@crate_index//:slog", - "@crate_index//:thiserror", "@crate_index//:tokio", "@crate_index//:tonic", ], diff --git a/rs/async_utils/Cargo.toml b/rs/async_utils/Cargo.toml index fd56035507e..78e8790f623 100644 --- a/rs/async_utils/Cargo.toml +++ b/rs/async_utils/Cargo.toml @@ -15,7 +15,6 @@ futures = { workspace = true } futures-util = { workspace = true } hyper = { workspace = true } slog = { workspace = true } -thiserror = { workspace = true } tokio = { workspace = true } tonic = { workspace = true } From 4e07bff48a610f5eb13b1535eb3119f11b327a11 Mon Sep 17 00:00:00 2001 From: IDX GitHub Automation Date: Mon, 4 Nov 2024 09:35:22 +0000 Subject: [PATCH 3/3] Automatically updated Cargo*.lock --- Cargo.lock | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e4b048748d..1a356546ed1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5428,7 +5428,6 @@ version = "0.9.0" dependencies = [ "anyhow", "async-stream", - "axum", "byte-unit", "bytes", "futures", @@ -5436,8 +5435,6 @@ dependencies = [ "hyper 1.5.0", "rand 0.8.5", "slog", - "sync_wrapper 1.0.1", - "thiserror", "tokio", "tonic", ] @@ -19957,7 +19954,6 @@ dependencies = [ "axum", "clap 4.5.20", "http 1.1.0", - "ic-async-utils", "itertools 0.12.1", "reqwest 0.12.8", "thiserror",