Skip to content

Commit c728e18

Browse files
committed
refactor(app): Define layer type aliases
this isn't a "simplification" so much as an outlining of the chunky types in this function signature. that said... it's subjectively nice to outline the definition of our layers into a `MetricsLayer<T, N>` that we can use as shorthand in the function signature of `layer(..)`. Signed-off-by: katelyn martin <[email protected]>
1 parent 8d12fda commit c728e18

File tree

1 file changed

+10
-10
lines changed
  • linkerd/app/outbound/src/http/logical/policy/route/backend

1 file changed

+10
-10
lines changed

linkerd/app/outbound/src/http/logical/policy/route/backend/metrics.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ type ResponseMetrics<L> = record_response::ResponseMetrics<
2424
<L as StreamLabel>::StatusLabels,
2525
>;
2626

27+
type MetricsLayer<T, N> = BodyDataLayer<RequestLayer<ResponseLayer<T, N>>>;
28+
type BodyDataLayer<N> = NewRecordBodyData<ExtractRecordBodyDataParams, N>;
29+
type RequestLayer<N> = NewCountRequests<ExtractRequestCount, N>;
30+
type ResponseLayer<T, N> = NewResponseDuration<
31+
T,
32+
ExtractRecordDurationParams<ResponseMetrics<<T as MkStreamLabel>::StreamLabel>>,
33+
N,
34+
>;
35+
2736
pub fn layer<T, N>(
2837
metrics: &RouteBackendMetrics<T::StreamLabel>,
29-
) -> impl svc::Layer<
30-
N,
31-
Service = NewRecordBodyData<
32-
ExtractRecordBodyDataParams,
33-
NewCountRequests<
34-
ExtractRequestCount,
35-
NewResponseDuration<T, ExtractRecordDurationParams<ResponseMetrics<T::StreamLabel>>, N>,
36-
>,
37-
>,
38-
> + Clone
38+
) -> impl svc::Layer<N, Service = MetricsLayer<T, N>> + Clone
3939
where
4040
T: MkStreamLabel,
4141
{

0 commit comments

Comments
 (0)