Skip to content

Commit

Permalink
refactor(app/test): remove connect_client(..)
Browse files Browse the repository at this point in the history
and once more, we remove a helper function that isn't doing quite so
much work, and whose signature contains deprecated hyper 1.0 types.

Signed-off-by: katelyn martin <kate@buoyant.io>
  • Loading branch information
cratelyn committed Dec 7, 2024
1 parent a7951e1 commit 15d1b09
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions linkerd/app/test/src/http_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
};
use futures::FutureExt;
use hyper::{body::HttpBody, Body};
use std::future::Future;
use tokio::task::JoinSet;
use tower::ServiceExt;
use tracing::Instrument;
Expand All @@ -30,7 +29,15 @@ pub async fn connect_and_accept(
tracing::info!(?res, "proxy serve task complete");
res
};
let (client, client_bg) = connect_client(client_settings, client_io).await;

let (client, conn) = client_settings
.handshake(client_io)
.await
.expect("Client must connect");
let client_bg = conn.map(|res| {
tracing::info!(?res, "Client background complete");
res.map_err(Error::from)
});

let mut bg = tokio::task::JoinSet::new();
bg.spawn(
Expand All @@ -55,22 +62,6 @@ pub async fn connect_and_accept(
(client, bg)
}

#[allow(deprecated)] // linkerd/linkerd2#8733
async fn connect_client(
client_settings: &mut ClientBuilder,
io: io::DuplexStream,
) -> (SendRequest<Body>, impl Future<Output = Result<(), Error>>) {
let (client, conn) = client_settings
.handshake(io)
.await
.expect("Client must connect");
let client_bg = conn.map(|res| {
tracing::info!(?res, "Client background complete");
res.map_err(Into::into)
});
(client, client_bg)
}

/// Collects a request or response body, returning it as a [`String`].
pub async fn body_to_string<T>(body: T) -> Result<String, Error>
where
Expand Down

0 comments on commit 15d1b09

Please sign in to comment.