Skip to content

Commit efba099

Browse files
authored
refactor(proxy/http): create linkerd-http-version crate (#3379)
* feat(proxy/http): create `linkerd-http-version` crate this outlines the http version type into its own crate. reëxports are added to make this a backwards compatible change, i.e. no changes to the public api of `linkerd-proxy-http` are performed here. Signed-off-by: katelyn martin <[email protected]> * docs(http/version): doc comments this adds some brief documentation comments to the crate. Signed-off-by: katelyn martin <[email protected]> --------- Signed-off-by: katelyn martin <[email protected]>
1 parent e4d7d57 commit efba099

File tree

6 files changed

+35
-3
lines changed

6 files changed

+35
-3
lines changed

Cargo.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,6 +1797,14 @@ dependencies = [
17971797
"url",
17981798
]
17991799

1800+
[[package]]
1801+
name = "linkerd-http-version"
1802+
version = "0.1.0"
1803+
dependencies = [
1804+
"http",
1805+
"thiserror",
1806+
]
1807+
18001808
[[package]]
18011809
name = "linkerd-identity"
18021810
version = "0.1.0"
@@ -2158,6 +2166,7 @@ dependencies = [
21582166
"linkerd-http-classify",
21592167
"linkerd-http-executor",
21602168
"linkerd-http-h2",
2169+
"linkerd-http-version",
21612170
"linkerd-io",
21622171
"linkerd-proxy-balance",
21632172
"linkerd-stack",

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ members = [
3333
"linkerd/http/prom",
3434
"linkerd/http/retry",
3535
"linkerd/http/route",
36+
"linkerd/http/version",
3637
"linkerd/identity",
3738
"linkerd/idle-cache",
3839
"linkerd/io",

linkerd/http/version/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "linkerd-http-version"
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+
HTTP version types.
10+
"""
11+
12+
[dependencies]
13+
http = "0.2"
14+
thiserror = "1"

linkerd/proxy/http/src/version.rs renamed to linkerd/http/version/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
//! HTTP version types.
2+
//!
3+
//! See [`Version`].
4+
15
use thiserror::Error;
26

7+
/// HTTP protocol version.
38
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
49
pub enum Version {
10+
/// HTTP/1
511
Http1,
12+
/// HTTP/2
613
H2,
714
}
815

16+
/// An unsupported HTTP version error.
917
#[derive(Debug, Error)]
1018
#[error("unsupported HTTP version {:?}", self.0)]
1119
pub struct Unsupported(http::Version);

linkerd/proxy/http/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ linkerd-detect = { path = "../../detect" }
4242
linkerd-duplex = { path = "../../duplex" }
4343
linkerd-error = { path = "../../error" }
4444
linkerd-http-box = { path = "../../http/box" }
45+
linkerd-http-classify = { path = "../../http/classify" }
4546
linkerd-http-executor = { path = "../../http/executor" }
4647
linkerd-http-h2 = { path = "../../http/h2" }
47-
linkerd-http-classify = { path = "../../http/classify" }
48+
linkerd-http-version = { path = "../../http/version" }
4849
linkerd-io = { path = "../../io" }
4950
linkerd-proxy-balance = { path = "../balance" }
5051
linkerd-stack = { path = "../../stack" }

linkerd/proxy/http/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub mod stream_timeouts;
2323
pub mod strip_header;
2424
pub mod timeout;
2525
pub mod upgrade;
26-
pub mod version;
2726

2827
pub use self::{
2928
balance::NewBalance,
@@ -41,7 +40,6 @@ pub use self::{
4140
stream_timeouts::{EnforceTimeouts, StreamTimeouts},
4241
strip_header::StripHeader,
4342
timeout::{NewTimeout, ResponseTimeout, ResponseTimeoutError},
44-
version::Version,
4543
};
4644
pub use http::{
4745
header::{self, HeaderMap, HeaderName, HeaderValue},
@@ -50,6 +48,7 @@ pub use http::{
5048
pub use hyper::body::HttpBody;
5149
pub use linkerd_http_box::{BoxBody, BoxRequest, BoxResponse, EraseResponse};
5250
pub use linkerd_http_executor::TracingExecutor;
51+
pub use linkerd_http_version::{self as version, Version};
5352

5453
#[derive(Clone, Debug)]
5554
pub struct HeaderPair(pub HeaderName, pub HeaderValue);

0 commit comments

Comments
 (0)