Skip to content

Commit

Permalink
refactor(http/retry): remove unused ResponseWithPeekTrailers<S> (#3541
Browse files Browse the repository at this point in the history
)

`ResponseWithPeekTrailers` wraps an inner service `S`.

upon inspection, it turns out that this structure is no longer used by
any code elsewhere in the project.

this commit removes `ResponseWithPeekTrailers`, its associated type
aliases, and its `tower::Service<T>` implementation.

Signed-off-by: katelyn martin <[email protected]>
  • Loading branch information
cratelyn authored Jan 17, 2025
1 parent 329bee2 commit 10bb285
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions linkerd/http/retry/src/peek_trailers.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use futures::{
future::{self, Either},
FutureExt, TryFutureExt,
FutureExt,
};
use http_body::Body;
use linkerd_http_box::BoxBody;
use linkerd_stack::Service;
use std::{
future::Future,
pin::Pin,
Expand Down Expand Up @@ -44,9 +43,6 @@ pub type WithPeekTrailersBody<B> = Either<
Pin<Box<dyn Future<Output = http::Response<PeekTrailersBody<B>>> + Send + 'static>>,
>;

#[derive(Clone, Debug)]
pub struct ResponseWithPeekTrailers<S>(pub(crate) S);

// === impl WithTrailers ===

impl<B: Body> PeekTrailersBody<B> {
Expand Down Expand Up @@ -185,34 +181,3 @@ where
hint
}
}

// === impl ResponseWithTrailers ===

type WrapTrailersFuture<E> = future::Map<
WithPeekTrailersBody<BoxBody>,
fn(http::Response<PeekTrailersBody>) -> Result<http::Response<PeekTrailersBody>, E>,
>;

impl<Req, S> Service<Req> for ResponseWithPeekTrailers<S>
where
S: Service<Req, Response = http::Response<BoxBody>>,
{
type Response = http::Response<PeekTrailersBody>;
type Error = S::Error;
type Future = future::AndThen<
S::Future,
WrapTrailersFuture<S::Error>,
fn(http::Response<BoxBody>) -> WrapTrailersFuture<S::Error>,
>;

fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.0.poll_ready(cx)
}

#[inline]
fn call(&mut self, req: Req) -> Self::Future {
self.0
.call(req)
.and_then(|rsp| PeekTrailersBody::map_response(rsp).map(Ok))
}
}

0 comments on commit 10bb285

Please sign in to comment.