Skip to content

Commit 5b2357b

Browse files
committed
refactor(proxy/http): create linkerd-http-stream-timeouts crate (#3382)
this commit outlines the stream timeout middleware, pulling it out of `linkerd-proxy-http` and into a standalone crate. again, reëxports are added to make this a backwards compatible change. Signed-off-by: katelyn martin <[email protected]>
1 parent 5e4ebb3 commit 5b2357b

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

Cargo.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,22 @@ dependencies = [
18291829
"url",
18301830
]
18311831

1832+
[[package]]
1833+
name = "linkerd-http-stream-timeouts"
1834+
version = "0.1.0"
1835+
dependencies = [
1836+
"futures",
1837+
"http",
1838+
"http-body",
1839+
"linkerd-error",
1840+
"linkerd-stack",
1841+
"parking_lot",
1842+
"pin-project",
1843+
"thiserror",
1844+
"tokio",
1845+
"tracing",
1846+
]
1847+
18321848
[[package]]
18331849
name = "linkerd-http-version"
18341850
version = "0.1.0"
@@ -2200,6 +2216,7 @@ dependencies = [
22002216
"linkerd-http-h2",
22012217
"linkerd-http-insert",
22022218
"linkerd-http-retain",
2219+
"linkerd-http-stream-timeouts",
22032220
"linkerd-http-version",
22042221
"linkerd-io",
22052222
"linkerd-proxy-balance",

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ members = [
3535
"linkerd/http/retain",
3636
"linkerd/http/retry",
3737
"linkerd/http/route",
38+
"linkerd/http/stream-timeouts",
3839
"linkerd/http/version",
3940
"linkerd/identity",
4041
"linkerd/idle-cache",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "linkerd-http-stream-timeouts"
3+
version = "0.1.0"
4+
authors = ["Linkerd Developers <[email protected]>"]
5+
license = "Apache-2.0"
6+
edition = "2021"
7+
publish = false
8+
description = """
9+
Tower middleware to express deadlines on streams.
10+
"""
11+
12+
[dependencies]
13+
futures = { version = "0.3", default-features = false }
14+
http = "0.2"
15+
http-body = "0.4"
16+
parking_lot = "0.12"
17+
pin-project = "1"
18+
thiserror = "1"
19+
tokio = { version = "1", default-features = false }
20+
tracing = "0.1"
21+
22+
linkerd-error = { path = "../../error" }
23+
linkerd-stack = { path = "../../stack" }

linkerd/proxy/http/src/stream_timeouts.rs renamed to linkerd/http/stream-timeouts/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Tower middleware to express deadlines on streams.
2+
//!
3+
//! See [`EnforceTimeouts<S>`].
4+
15
use futures::FutureExt;
26
use linkerd_error::{Error, Result};
37
use linkerd_stack as svc;
@@ -345,9 +349,9 @@ where
345349

346350
// === impl RequestBody ===
347351

348-
impl<B> crate::HttpBody for RequestBody<B>
352+
impl<B> http_body::Body for RequestBody<B>
349353
where
350-
B: crate::HttpBody<Error = Error>,
354+
B: http_body::Body<Error = Error>,
351355
{
352356
type Data = B::Data;
353357
type Error = Error;
@@ -405,9 +409,9 @@ where
405409

406410
// === impl ResponseBody ===
407411

408-
impl<B> crate::HttpBody for ResponseBody<B>
412+
impl<B> http_body::Body for ResponseBody<B>
409413
where
410-
B: crate::HttpBody<Error = Error>,
414+
B: http_body::Body<Error = Error>,
411415
{
412416
type Data = B::Data;
413417
type Error = Error;

linkerd/proxy/http/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ linkerd-http-executor = { path = "../../http/executor" }
4747
linkerd-http-h2 = { path = "../../http/h2" }
4848
linkerd-http-insert = { path = "../../http/insert" }
4949
linkerd-http-retain = { path = "../../http/retain" }
50+
linkerd-http-stream-timeouts = { path = "../../http/stream-timeouts" }
5051
linkerd-http-version = { path = "../../http/version" }
5152
linkerd-io = { path = "../../io" }
5253
linkerd-proxy-balance = { path = "../balance" }

linkerd/proxy/http/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pub mod normalize_uri;
1616
pub mod orig_proto;
1717
mod override_authority;
1818
mod server;
19-
pub mod stream_timeouts;
2019
pub mod strip_header;
2120
pub mod timeout;
2221
pub mod upgrade;
@@ -33,7 +32,6 @@ pub use self::{
3332
normalize_uri::{MarkAbsoluteForm, NewNormalizeUri},
3433
override_authority::{AuthorityOverride, NewOverrideAuthority},
3534
server::{NewServeHttp, Params as ServerParams, ServeHttp},
36-
stream_timeouts::{EnforceTimeouts, StreamTimeouts},
3735
strip_header::StripHeader,
3836
timeout::{NewTimeout, ResponseTimeout, ResponseTimeoutError},
3937
};
@@ -47,6 +45,7 @@ pub use linkerd_http_classify as classify;
4745
pub use linkerd_http_executor::TracingExecutor;
4846
pub use linkerd_http_insert as insert;
4947
pub use linkerd_http_retain::{self as retain, Retain};
48+
pub use linkerd_http_stream_timeouts::{self as stream_timeouts, EnforceTimeouts, StreamTimeouts};
5049
pub use linkerd_http_version::{self as version, Version};
5150

5251
#[derive(Clone, Debug)]

0 commit comments

Comments
 (0)