Skip to content

Commit

Permalink
refactor(proxy/http): create linkerd-http-retain crate (#3382)
Browse files Browse the repository at this point in the history
this moves the `Retain` middleware from `linkerd-proxy-http` into a new
`linkerd-http-retain` crate.

as previously, reëxports are added to make this a backwards compatible
change.

this moves another http body middleware out of the proxy's core http
crate. great news.

Signed-off-by: katelyn martin <[email protected]>
  • Loading branch information
cratelyn committed Nov 22, 2024
1 parent f3f9632 commit 5e4ebb3
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1782,6 +1782,17 @@ dependencies = [
"tokio",
]

[[package]]
name = "linkerd-http-retain"
version = "0.1.0"
dependencies = [
"http",
"http-body",
"linkerd-stack",
"pin-project",
"tower",
]

[[package]]
name = "linkerd-http-retry"
version = "0.1.0"
Expand Down Expand Up @@ -2188,6 +2199,7 @@ dependencies = [
"linkerd-http-executor",
"linkerd-http-h2",
"linkerd-http-insert",
"linkerd-http-retain",
"linkerd-http-version",
"linkerd-io",
"linkerd-proxy-balance",
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ members = [
"linkerd/http/insert",
"linkerd/http/metrics",
"linkerd/http/prom",
"linkerd/http/retain",
"linkerd/http/retry",
"linkerd/http/route",
"linkerd/http/version",
Expand Down
20 changes: 20 additions & 0 deletions linkerd/http/retain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "linkerd-http-retain"
version = "0.1.0"
authors = ["Linkerd Developers <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
publish = false
description = """
Tower middleware to manage service lifecycles.
This is mostly intended to support cache eviction.
"""

[dependencies]
http = "0.2"
http-body = "0.4"
pin-project = "1"
tower = { version = "0.4", default-features = false }

linkerd-stack = { path = "../../stack" }
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Provides a middleware that holds an inner service as long as responses are
//! being processed.
//! Tower middleware to manage service lifecycles.
//!
//! Provides a [`Retain<S, B>`] middleware that holds an inner service as long as responses are
//! being processed. This is mostly intended to support cache eviction.
use linkerd_stack::layer;
use pin_project::pin_project;
Expand Down
1 change: 1 addition & 0 deletions linkerd/proxy/http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ linkerd-http-classify = { path = "../../http/classify" }
linkerd-http-executor = { path = "../../http/executor" }
linkerd-http-h2 = { path = "../../http/h2" }
linkerd-http-insert = { path = "../../http/insert" }
linkerd-http-retain = { path = "../../http/retain" }
linkerd-http-version = { path = "../../http/version" }
linkerd-io = { path = "../../io" }
linkerd-proxy-balance = { path = "../balance" }
Expand Down
3 changes: 1 addition & 2 deletions linkerd/proxy/http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ mod header_from_target;
pub mod normalize_uri;
pub mod orig_proto;
mod override_authority;
mod retain;
mod server;
pub mod stream_timeouts;
pub mod strip_header;
Expand All @@ -33,7 +32,6 @@ pub use self::{
header_from_target::NewHeaderFromTarget,
normalize_uri::{MarkAbsoluteForm, NewNormalizeUri},
override_authority::{AuthorityOverride, NewOverrideAuthority},
retain::Retain,
server::{NewServeHttp, Params as ServerParams, ServeHttp},
stream_timeouts::{EnforceTimeouts, StreamTimeouts},
strip_header::StripHeader,
Expand All @@ -48,6 +46,7 @@ pub use linkerd_http_box::{BoxBody, BoxRequest, BoxResponse, EraseResponse};
pub use linkerd_http_classify as classify;
pub use linkerd_http_executor::TracingExecutor;
pub use linkerd_http_insert as insert;
pub use linkerd_http_retain::{self as retain, Retain};
pub use linkerd_http_version::{self as version, Version};

#[derive(Clone, Debug)]
Expand Down

0 comments on commit 5e4ebb3

Please sign in to comment.