Skip to content

Commit affd645

Browse files
authored
outbound: Make the HTTP server stack generic (#953)
The HTTP server stack is unnecessarily bound to a target type. In order to support more flexible stack composition, this change makes the outbound HTTP server stack generic over its target type.
1 parent cac988e commit affd645

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

linkerd/app/outbound/src/http/detect.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use linkerd_app_core::{
33
config::{ProxyConfig, ServerConfig},
44
detect, io, svc, Error,
55
};
6+
use tracing::debug_span;
67

78
impl<T> Outbound<T> {
89
pub fn push_detect_http<TSvc, H, HSvc, I>(
@@ -45,6 +46,7 @@ impl<T> Outbound<T> {
4546
)
4647
.push(http::NewServeHttp::layer(h2_settings, rt.drain.clone()))
4748
.push_map_target(http::Logical::from)
49+
.instrument(|(v, _): &(http::Version, _)| debug_span!("http", %v))
4850
.push(svc::UnwrapOr::layer(
4951
tcp.clone()
5052
.push_on_response(svc::MapTargetLayer::new(io::EitherIo::Right))

linkerd/app/outbound/src/http/server.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
use crate::{http, trace_labels, Outbound};
22
use linkerd_app_core::{config, errors, http_tracing, svc, Error};
3-
use tracing::debug_span;
43

5-
impl<H, HSvc> Outbound<H>
6-
where
7-
H: svc::NewService<http::Logical, Service = HSvc> + Clone + Send + 'static,
8-
HSvc: svc::Service<http::Request<http::BoxBody>, Response = http::Response<http::BoxBody>>,
9-
HSvc: Send + 'static,
10-
HSvc::Error: Into<Error>,
11-
HSvc::Future: Send,
12-
{
13-
pub fn push_http_server(
4+
impl<N> Outbound<N> {
5+
pub fn push_http_server<T, NSvc>(
146
self,
157
) -> Outbound<
168
impl svc::NewService<
17-
http::Logical,
9+
T,
1810
Service = impl svc::Service<
1911
http::Request<http::BoxBody>,
2012
Response = http::Response<http::BoxBody>,
2113
Error = Error,
2214
Future = impl Send,
2315
> + Clone,
2416
> + Clone,
25-
> {
17+
>
18+
where
19+
T: svc::Param<http::normalize_uri::DefaultAuthority>,
20+
N: svc::NewService<T, Service = NSvc> + Clone + Send + 'static,
21+
NSvc: svc::Service<http::Request<http::BoxBody>, Response = http::Response<http::BoxBody>>,
22+
NSvc: Send + 'static,
23+
NSvc::Error: Into<Error>,
24+
NSvc::Future: Send,
25+
{
2626
let Self {
2727
config,
2828
runtime: rt,
@@ -37,7 +37,7 @@ where
3737
} = config.proxy;
3838

3939
let stack = http
40-
.check_new_service::<http::Logical, _>()
40+
.check_new_service::<T, _>()
4141
.push_on_response(
4242
svc::layers()
4343
.push(http::BoxRequest::layer())
@@ -62,8 +62,7 @@ where
6262
.push(http::NewNormalizeUri::layer())
6363
// Record when a HTTP/1 URI originated in absolute form
6464
.push_on_response(http::normalize_uri::MarkAbsoluteForm::layer())
65-
.instrument(|l: &http::Logical| debug_span!("http", v = %l.protocol))
66-
.check_new_service::<http::Logical, http::Request<http::BoxBody>>();
65+
.check_new_service::<T, http::Request<http::BoxBody>>();
6766

6867
Outbound {
6968
config,

0 commit comments

Comments
 (0)