From 984505fb4165b7b4bd5eec2c18a687297f419df5 Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Sun, 1 Dec 2024 00:00:00 +0000 Subject: [PATCH] refactor(app/test): remove unused test `Server` interfaces this `Server` type is not used by any tests. this commit removes it, to help facilitate the upgrade to the hyper 1.0 major release. see . Signed-off-by: katelyn martin --- linkerd/app/test/src/http_util.rs | 71 +------------------------------ 1 file changed, 2 insertions(+), 69 deletions(-) diff --git a/linkerd/app/test/src/http_util.rs b/linkerd/app/test/src/http_util.rs index 72abb3e97d..9b68f1a783 100644 --- a/linkerd/app/test/src/http_util.rs +++ b/linkerd/app/test/src/http_util.rs @@ -1,11 +1,10 @@ use crate::{ - app_core::{svc, tls, Error}, + app_core::{svc, Error}, io, ContextError, }; use futures::FutureExt; use hyper::{body::HttpBody, Body, Request, Response}; -use parking_lot::Mutex; -use std::{future::Future, sync::Arc}; +use std::future::Future; use tokio::task::JoinHandle; use tower::{util::ServiceExt, Service}; use tracing::Instrument; @@ -13,31 +12,8 @@ use tracing::Instrument; #[allow(deprecated)] // linkerd/linkerd2#8733 use hyper::client::conn::{Builder as ClientBuilder, SendRequest}; -pub struct Server { - #[allow(deprecated)] // linkerd/linkerd2#8733 - settings: hyper::server::conn::Http, - f: HandleFuture, -} - -type HandleFuture = Box) -> Result, Error>) + Send>; - type BoxServer = svc::BoxTcp; -impl Default for Server { - fn default() -> Self { - Self { - #[allow(deprecated)] // linkerd/linkerd2#8733 - settings: hyper::server::conn::Http::new(), - f: Box::new(|_| { - Ok(Response::builder() - .status(http::status::StatusCode::NOT_FOUND) - .body(Body::empty()) - .expect("known status code is fine")) - }), - } - } -} - pub async fn run_proxy(mut server: BoxServer) -> (io::DuplexStream, JoinHandle>) { let (client_io, server_io) = io::duplex(4096); let f = server @@ -131,46 +107,3 @@ where .to_owned(); Ok(body) } - -impl Server { - pub fn http1(mut self) -> Self { - self.settings.http1_only(true); - self - } - - pub fn http2(mut self) -> Self { - self.settings.http2_only(true); - self - } - - pub fn new(mut f: impl (FnMut(Request) -> Response) + Send + 'static) -> Self { - Self { - f: Box::new(move |req| Ok::<_, Error>(f(req))), - ..Default::default() - } - } - - pub fn run(self) -> impl (FnMut(E) -> io::Result) + Send + 'static - where - E: std::fmt::Debug, - E: svc::Param, - { - let Self { f, settings } = self; - let f = Arc::new(Mutex::new(f)); - move |endpoint| { - let span = tracing::debug_span!("server::run", ?endpoint).or_current(); - let _e = span.enter(); - let f = f.clone(); - let (client_io, server_io) = crate::io::duplex(4096); - let svc = hyper::service::service_fn(move |request: Request| { - let f = f.clone(); - async move { - tracing::info!(?request); - f.lock()(request) - } - }); - tokio::spawn(settings.serve_connection(server_io, svc).in_current_span()); - Ok(io::BoxedIo::new(client_io)) - } - } -}