Skip to content

Commit 8cde1d4

Browse files
authored
svc: Update stack diagnostic checks (#642)
This change updates and extends the diagnostic stack checks that we use during development. No functional changes.
1 parent 1503b63 commit 8cde1d4

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed

linkerd/app/core/src/svc.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ impl<L> Layers<L> {
5555
Layers(Pair::new(self.0, outer))
5656
}
5757

58-
pub fn push_map_target<M: Clone>(
59-
self,
60-
map_target: M,
61-
) -> Layers<Pair<L, stack::MapTargetLayer<M>>> {
58+
pub fn push_map_target<M>(self, map_target: M) -> Layers<Pair<L, stack::MapTargetLayer<M>>> {
6259
self.push(stack::MapTargetLayer::new(map_target))
6360
}
6461

@@ -280,25 +277,43 @@ impl<S> Stack<S> {
280277
}
281278

282279
/// Validates that this stack serves T-typed targets.
283-
pub fn check_new_service<T>(self) -> Self
280+
pub fn check_new<T>(self) -> Self
284281
where
285282
S: NewService<T>,
286283
{
287284
self
288285
}
289286

290-
/// Validates that this stack can be cloned
291-
pub fn check_clone(self) -> Self
287+
pub fn check_new_clone<T>(self) -> Self
292288
where
293-
S: Clone,
289+
S: NewService<T>,
290+
S::Service: Clone,
294291
{
295292
self
296293
}
297294

298-
pub fn check_new_clone_service<T>(self) -> Self
295+
/// Validates that this stack serves T-typed targets.
296+
pub fn check_new_service<T, Req>(self) -> Self
299297
where
300298
S: NewService<T>,
301-
S::Service: Clone,
299+
S::Service: Service<Req>,
300+
{
301+
self
302+
}
303+
304+
/// Validates that this stack serves T-typed targets.
305+
pub fn check_clone_new_service<T, Req>(self) -> Self
306+
where
307+
S: NewService<T> + Clone,
308+
S::Service: Service<Req>,
309+
{
310+
self
311+
}
312+
313+
/// Validates that this stack can be cloned
314+
pub fn check_clone(self) -> Self
315+
where
316+
S: Clone,
302317
{
303318
self
304319
}
@@ -327,15 +342,6 @@ impl<S> Stack<S> {
327342
self
328343
}
329344

330-
/// Validates that this stack serves T-typed targets.
331-
pub fn check_new_service_routes<T, Req>(self) -> Self
332-
where
333-
S: NewService<T>,
334-
S::Service: Service<Req>,
335-
{
336-
self
337-
}
338-
339345
/// Validates that this stack serves T-typed targets.
340346
pub fn check_make_service<T, U>(self) -> Self
341347
where

linkerd/app/inbound/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl Config {
206206
// Sets the per-route response classifier as a request
207207
// extension.
208208
.push(classify::Layer::new())
209-
.check_new_clone_service::<dst::Route>();
209+
.check_new_clone::<dst::Route>();
210210

211211
// An HTTP client is created for each target via the endpoint stack.
212212
let http_target_cache = http_endpoint
@@ -245,7 +245,7 @@ impl Config {
245245
))
246246
.into_new_service()
247247
// Caches profile stacks.
248-
.check_new_service_routes::<Profile, Target>()
248+
.check_new_service::<Profile, Target>()
249249
.cache(
250250
svc::layers().push_on_response(
251251
svc::layers()
@@ -261,7 +261,7 @@ impl Config {
261261
.instrument(|p: &Profile| info_span!("profile", addr = %p.addr()))
262262
.check_make_service::<Profile, Target>()
263263
.push(router::Layer::new(|()| ProfileTarget))
264-
.check_new_service_routes::<(), Target>()
264+
.check_new_service::<(), Target>()
265265
.new_service(());
266266

267267
svc::stack(http_profile_cache)
@@ -359,7 +359,7 @@ impl Config {
359359
.push(router::Layer::new(RequestTarget::from))
360360
// Used by tap.
361361
.push_http_insert_target()
362-
.check_new_service::<tls::accept::Meta>()
362+
.check_new_service::<tls::accept::Meta, http::Request<_>>()
363363
.push_on_response(
364364
svc::layers()
365365
.push(http_admit_request)
@@ -368,7 +368,7 @@ impl Config {
368368
.box_http_request()
369369
.box_http_response(),
370370
)
371-
.check_new_service::<tls::accept::Meta>()
371+
.check_new_service::<tls::accept::Meta, http::Request<_>>()
372372
.instrument(|src: &tls::accept::Meta| {
373373
info_span!(
374374
"source",

linkerd/app/outbound/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,21 +334,17 @@ impl Config {
334334
.check_service::<Concrete<HttpEndpoint>>();
335335

336336
let http_profile_route_proxy = svc::proxies()
337-
.check_new_clone_service::<dst::Route>()
338337
.push(metrics.http_route_actual.into_layer::<classify::Response>())
339338
// Sets an optional retry policy.
340339
.push(retry::layer(metrics.http_route_retry))
341-
.check_new_clone_service::<dst::Route>()
342340
// Sets an optional request timeout.
343341
.push(http::MakeTimeoutLayer::default())
344-
.check_new_clone_service::<dst::Route>()
345342
// Records per-route metrics.
346343
.push(metrics.http_route.into_layer::<classify::Response>())
347-
.check_new_clone_service::<dst::Route>()
348344
// Sets the per-route response classifier as a request
349345
// extension.
350346
.push(classify::Layer::new())
351-
.check_new_clone_service::<dst::Route>();
347+
.check_new_clone::<dst::Route>();
352348

353349
// Routes `Logical` targets to a cached `Profile` stack, i.e. so that profile
354350
// resolutions are shared even as the type of request may vary.
@@ -388,7 +384,7 @@ impl Config {
388384
.instrument(|_: &Profile| info_span!("profile"))
389385
.check_make_service::<Profile, Logical<HttpEndpoint>>()
390386
.push(router::Layer::new(|()| ProfilePerTarget))
391-
.check_new_service_routes::<(), Logical<HttpEndpoint>>()
387+
.check_new_service::<(), Logical<HttpEndpoint>>()
392388
.new_service(());
393389

394390
// Routes requests to their logical target.
@@ -487,7 +483,7 @@ impl Config {
487483
.push_make_ready()
488484
.push_timeout(dispatch_timeout)
489485
.push(router::Layer::new(LogicalPerRequest::from))
490-
.check_new_service::<listen::Addrs>()
486+
.check_new_service::<listen::Addrs, http::Request<_>>()
491487
// Used by tap.
492488
.push_http_insert_target()
493489
.push_on_response(
@@ -500,7 +496,7 @@ impl Config {
500496
.instrument(
501497
|addrs: &listen::Addrs| info_span!("source", target.addr = %addrs.target_addr()),
502498
)
503-
.check_new_service::<listen::Addrs>()
499+
.check_new_service::<listen::Addrs, http::Request<_>>()
504500
.into_inner()
505501
.into_make_service();
506502

0 commit comments

Comments
 (0)