Skip to content

Commit 4422c6d

Browse files
authored
app: Move retry types into the app-outbound crate (#1378)
The retry crate is hardcoded to use the `linkerd_app_core::dst::Route` type as its target. This is inflexible, especially if we want to reorganize the outbound stack to support things like header-based overrides. This change movers the retry layer into the outbound crate so that it can be changed to use outbound-specific types. No functional changes.
1 parent 660289c commit 4422c6d

File tree

8 files changed

+20
-18
lines changed

8 files changed

+20
-18
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,6 @@ dependencies = [
839839
"linkerd-exp-backoff",
840840
"linkerd-http-classify",
841841
"linkerd-http-metrics",
842-
"linkerd-http-retry",
843842
"linkerd-identity",
844843
"linkerd-io",
845844
"linkerd-meshtls",
@@ -856,7 +855,6 @@ dependencies = [
856855
"linkerd-proxy-tcp",
857856
"linkerd-proxy-transport",
858857
"linkerd-reconnect",
859-
"linkerd-retry",
860858
"linkerd-service-profiles",
861859
"linkerd-stack",
862860
"linkerd-stack-metrics",
@@ -966,11 +964,13 @@ dependencies = [
966964
"hyper",
967965
"linkerd-app-core",
968966
"linkerd-app-test",
967+
"linkerd-http-classify",
969968
"linkerd-http-retry",
970969
"linkerd-identity",
971970
"linkerd-io",
972971
"linkerd-meshtls",
973972
"linkerd-meshtls-rustls",
973+
"linkerd-retry",
974974
"linkerd-tracing",
975975
"parking_lot",
976976
"pin-project",

linkerd/app/core/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ linkerd-error-respond = { path = "../../error-respond" }
3232
linkerd-exp-backoff = { path = "../../exp-backoff" }
3333
linkerd-http-classify = { path = "../../http-classify" }
3434
linkerd-http-metrics = { path = "../../http-metrics" }
35-
linkerd-http-retry = { path = "../../http-retry" }
3635
linkerd-identity = { path = "../../identity" }
3736
linkerd-io = { path = "../../io" }
3837
linkerd-meshtls = { path = "../../meshtls", default-features = false }
@@ -49,7 +48,6 @@ linkerd-proxy-tap = { path = "../../proxy/tap" }
4948
linkerd-proxy-tcp = { path = "../../proxy/tcp" }
5049
linkerd-proxy-transport = { path = "../../proxy/transport" }
5150
linkerd-reconnect = { path = "../../reconnect" }
52-
linkerd-retry = { path = "../../retry" }
5351
linkerd-service-profiles = { path = "../../service-profiles" }
5452
linkerd-stack = { path = "../../stack" }
5553
linkerd-stack-metrics = { path = "../../stack/metrics" }

linkerd/app/core/src/classify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn h2_error(err: &Error) -> String {
214214
// === impl Class ===
215215

216216
impl Class {
217-
pub(super) fn is_failure(&self) -> bool {
217+
pub fn is_failure(&self) -> bool {
218218
matches!(
219219
self,
220220
Class::Default(SuccessOrFailure::Failure)

linkerd/app/core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ pub mod errors;
4141
pub mod http_tracing;
4242
pub mod metrics;
4343
pub mod proxy;
44-
pub mod retry;
4544
pub mod serve;
4645
pub mod svc;
4746
pub mod telemetry;

linkerd/app/outbound/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ bytes = "1"
1919
http = "0.2"
2020
futures = { version = "0.3", default-features = false }
2121
linkerd-app-core = { path = "../core" }
22+
linkerd-http-classify = { path = "../../http-classify" }
2223
linkerd-http-retry = { path = "../../http-retry" }
2324
linkerd-identity = { path = "../../identity" }
25+
linkerd-retry = { path = "../../retry" }
2426
parking_lot = "0.11"
2527
thiserror = "1.0"
2628
tokio = { version = "1", features = ["sync"] }

linkerd/app/outbound/src/http.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod endpoint;
33
pub mod logical;
44
mod proxy_connection_close;
55
mod require_id_header;
6+
mod retry;
67
mod server;
78
mod strip_proxy_error;
89

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{CanonicalDstHeader, Concrete, Endpoint, Logical};
1+
use super::{retry, CanonicalDstHeader, Concrete, Endpoint, Logical};
22
use crate::{endpoint, resolve, stack_labels, Outbound};
33
use linkerd_app_core::{
44
classify, config, dst, profiles,
@@ -8,7 +8,7 @@ use linkerd_app_core::{
88
http,
99
resolve::map_endpoint,
1010
},
11-
retry, svc, Error, Infallible,
11+
svc, Error, Infallible,
1212
};
1313
use tracing::debug_span;
1414

linkerd/app/core/src/retry.rs renamed to linkerd/app/outbound/src/http/retry.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
use super::classify;
2-
use super::dst::Route;
3-
use super::http_metrics::retries::Handle;
4-
use super::metrics::HttpRouteRetry;
5-
use crate::profiles;
61
use futures::future;
7-
use linkerd_error::Error;
2+
use linkerd_app_core::{
3+
classify,
4+
dst::Route,
5+
http_metrics::retries::Handle,
6+
metrics::HttpRouteRetry,
7+
profiles,
8+
proxy::http::{ClientHandle, HttpBody},
9+
svc::{layer, Either, Param},
10+
Error,
11+
};
812
use linkerd_http_classify::{Classify, ClassifyEos, ClassifyResponse};
913
use linkerd_http_retry::ReplayBody;
10-
use linkerd_proxy_http::ClientHandle;
1114
use linkerd_retry as retry;
12-
use linkerd_stack::{layer, Either, Param};
1315
use std::sync::Arc;
1416

1517
pub fn layer<N>(
@@ -60,7 +62,7 @@ impl retry::NewPolicy<Route> for NewRetryPolicy {
6062

6163
impl<A, B, E> retry::Policy<http::Request<ReplayBody<A>>, http::Response<B>, E> for RetryPolicy
6264
where
63-
A: http_body::Body + Unpin,
65+
A: HttpBody + Unpin,
6466
A::Error: Into<Error>,
6567
{
6668
type Future = future::Ready<Self>;
@@ -125,7 +127,7 @@ where
125127

126128
impl<A, B, E> retry::PrepareRequest<http::Request<A>, http::Response<B>, E> for RetryPolicy
127129
where
128-
A: http_body::Body + Unpin,
130+
A: HttpBody + Unpin,
129131
A::Error: Into<Error>,
130132
{
131133
type RetryRequest = http::Request<ReplayBody<A>>;

0 commit comments

Comments
 (0)