Skip to content

Commit

Permalink
replace FutureService with Tower's upstream impl (#839)
Browse files Browse the repository at this point in the history
Tower 0.4 included a `FutureService` type which is basically identical
to the version we implemented for converting a `MakeService` into a
`NewService`. This branch replaces our implementation with the upstream
implementation from Tower.

It was necessary to add `MapErr` layers to convert the error types into
boxed errors, since our `FutureService` did that automatically, while
Tower's does not.
  • Loading branch information
hawkw authored Jan 14, 2021
1 parent c39f51d commit a209634
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 62 deletions.
6 changes: 5 additions & 1 deletion linkerd/app/core/src/svc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ use tower::{
make::MakeService,
};
pub use tower::{
layer::Layer, service_fn as mk, spawn_ready::SpawnReady, util::Either, Service, ServiceExt,
layer::Layer,
service_fn as mk,
spawn_ready::SpawnReady,
util::{Either, MapErrLayer},
Service, ServiceExt,
};

#[derive(Clone, Debug)]
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/outbound/src/http/logical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ where
.push(svc::FailFast::layer("HTTP Balancer", dispatch_timeout))
.push(metrics.stack.layer(stack_labels("http", "concrete"))),
)
.push(svc::MapErrLayer::new(Into::into))
.into_new_service()
.check_new_service::<Concrete, http::Request<_>>()
.instrument(|c: &Concrete| match c.resolve.as_ref() {
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/outbound/src/ingress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ where
.into_inner();

svc::stack(http)
.push_on_response(svc::MapErrLayer::new(Into::into))
.check_new_service::<http::Logical, http::Request<_>>()
.push_map_target(http::Logical::from)
.push(profiles::discover::layer(
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/outbound/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ where
let tcp_forward = svc::stack(tcp_connect)
.push_make_thunk()
.push_on_response(tcp::Forward::layer())
.push(svc::MapErrLayer::new(Into::into))
.into_new_service()
.push_on_response(metrics.stack.layer(stack_labels("tcp", "forward")))
.push_map_target(tcp::Endpoint::from_logical(
Expand Down
59 changes: 0 additions & 59 deletions linkerd/stack/src/future_service.rs

This file was deleted.

3 changes: 1 addition & 2 deletions linkerd/stack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod box_future;
mod box_new_service;
mod fail;
mod fail_on_error;
mod future_service;
pub mod layer;
pub mod make_thunk;
pub mod map_target;
Expand All @@ -25,7 +24,6 @@ pub use self::{
box_new_service::BoxNewService,
fail::Fail,
fail_on_error::FailOnError,
future_service::FutureService,
make_thunk::MakeThunk,
map_target::{MapTarget, MapTargetLayer, MapTargetService},
new_service::NewService,
Expand All @@ -39,3 +37,4 @@ pub use self::{
unwrap_or::NewUnwrapOr,
};
pub use tower::util::Either;
pub use tower::util::{future_service, FutureService};

0 comments on commit a209634

Please sign in to comment.