Skip to content

Commit 349d188

Browse files
committed
refactor(app/integration): remove Request, Response aliases
see linkerd/linkerd2#8733. this commit removes two type aliases from our test client implementation. these are each tied to the defunct `hyper::Body` type. since much of this code was originally written (between 2017 and 2020) we've since developed some patterns / idioms elsewhere for dealing with request and response bodies. to help set the stage for tweaks to which interfaces need `hyper::body::Incoming`, which types work with our general default of `BoxBody`, and which can be generic across arbitrary `B`-typed bodies, we remove these aliases and provide the body parameter to `Request` and `Response`. Signed-off-by: katelyn martin <[email protected]>
1 parent c18d469 commit 349d188

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

linkerd/app/integration/src/client.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use super::*;
2+
use http::{Request, Response};
23
use linkerd_app_core::proxy::http::TracingExecutor;
34
use parking_lot::Mutex;
45
use std::io;
@@ -7,9 +8,10 @@ use tokio_rustls::rustls::{self, ClientConfig};
78
use tracing::info_span;
89

910
type ClientError = hyper::Error;
10-
type Request = http::Request<hyper::Body>;
11-
type Response = http::Response<hyper::Body>;
12-
type Sender = mpsc::UnboundedSender<(Request, oneshot::Sender<Result<Response, ClientError>>)>;
11+
type Sender = mpsc::UnboundedSender<(
12+
Request<hyper::Body>,
13+
oneshot::Sender<Result<Response<hyper::Body>, ClientError>>,
14+
)>;
1315

1416
#[derive(Clone)]
1517
pub struct TlsConfig {
@@ -133,11 +135,12 @@ impl Client {
133135
pub fn request(
134136
&self,
135137
builder: http::request::Builder,
136-
) -> impl Future<Output = Result<Response, ClientError>> + Send + Sync + 'static {
138+
) -> impl Future<Output = Result<Response<hyper::Body>, ClientError>> + Send + Sync + 'static
139+
{
137140
self.send_req(builder.body(Bytes::new().into()).unwrap())
138141
}
139142

140-
pub async fn request_body(&self, req: Request) -> Response {
143+
pub async fn request_body(&self, req: Request<hyper::Body>) -> Response<hyper::Body> {
141144
self.send_req(req).await.expect("response")
142145
}
143146

@@ -156,8 +159,9 @@ impl Client {
156159
#[tracing::instrument(skip(self))]
157160
pub(crate) fn send_req(
158161
&self,
159-
mut req: Request,
160-
) -> impl Future<Output = Result<Response, ClientError>> + Send + Sync + 'static {
162+
mut req: Request<hyper::Body>,
163+
) -> impl Future<Output = Result<Response<hyper::Body>, ClientError>> + Send + Sync + 'static
164+
{
161165
if req.uri().scheme().is_none() {
162166
if self.tls.is_some() {
163167
*req.uri_mut() = format!("https://{}{}", self.authority, req.uri().path())
@@ -228,8 +232,10 @@ fn run(
228232
version: Run,
229233
tls: Option<TlsConfig>,
230234
) -> (Sender, JoinHandle<()>, Running) {
231-
let (tx, rx) =
232-
mpsc::unbounded_channel::<(Request, oneshot::Sender<Result<Response, ClientError>>)>();
235+
let (tx, rx) = mpsc::unbounded_channel::<(
236+
Request<hyper::Body>,
237+
oneshot::Sender<Result<Response<hyper::Body>, ClientError>>,
238+
)>();
233239

234240
let test_name = thread_name();
235241
let absolute_uris = if let Run::Http1 { absolute_uris } = version {

0 commit comments

Comments
 (0)