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 <kate@buoyant.io>

* docs(http/version): doc comments

this adds some brief documentation comments to the crate.

Signed-off-by: katelyn martin <kate@buoyant.io>

---------

Signed-off-by: katelyn martin <kate@buoyant.io>
This commit is contained in:
katelyn martin 2024-11-21 15:55:39 -05:00 committed by GitHub
parent e4d7d5782d
commit efba099ac5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 35 additions and 3 deletions

View File

@ -1797,6 +1797,14 @@ dependencies = [
"url",
]
[[package]]
name = "linkerd-http-version"
version = "0.1.0"
dependencies = [
"http",
"thiserror",
]
[[package]]
name = "linkerd-identity"
version = "0.1.0"
@ -2158,6 +2166,7 @@ dependencies = [
"linkerd-http-classify",
"linkerd-http-executor",
"linkerd-http-h2",
"linkerd-http-version",
"linkerd-io",
"linkerd-proxy-balance",
"linkerd-stack",

View File

@ -33,6 +33,7 @@ members = [
"linkerd/http/prom",
"linkerd/http/retry",
"linkerd/http/route",
"linkerd/http/version",
"linkerd/identity",
"linkerd/idle-cache",
"linkerd/io",

View File

@ -0,0 +1,14 @@
[package]
name = "linkerd-http-version"
version = "0.1.0"
authors = ["Linkerd Developers <cncf-linkerd-dev@lists.cncf.io>"]
license = "Apache-2.0"
edition = "2021"
publish = false
description = """
HTTP version types.
"""
[dependencies]
http = "0.2"
thiserror = "1"

View File

@ -1,11 +1,19 @@
//! HTTP version types.
//!
//! See [`Version`].
use thiserror::Error;
/// HTTP protocol version.
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum Version {
/// HTTP/1
Http1,
/// HTTP/2
H2,
}
/// An unsupported HTTP version error.
#[derive(Debug, Error)]
#[error("unsupported HTTP version {:?}", self.0)]
pub struct Unsupported(http::Version);

View File

@ -42,9 +42,10 @@ linkerd-detect = { path = "../../detect" }
linkerd-duplex = { path = "../../duplex" }
linkerd-error = { path = "../../error" }
linkerd-http-box = { path = "../../http/box" }
linkerd-http-classify = { path = "../../http/classify" }
linkerd-http-executor = { path = "../../http/executor" }
linkerd-http-h2 = { path = "../../http/h2" }
linkerd-http-classify = { path = "../../http/classify" }
linkerd-http-version = { path = "../../http/version" }
linkerd-io = { path = "../../io" }
linkerd-proxy-balance = { path = "../balance" }
linkerd-stack = { path = "../../stack" }

View File

@ -23,7 +23,6 @@ pub mod stream_timeouts;
pub mod strip_header;
pub mod timeout;
pub mod upgrade;
pub mod version;
pub use self::{
balance::NewBalance,
@ -41,7 +40,6 @@ pub use self::{
stream_timeouts::{EnforceTimeouts, StreamTimeouts},
strip_header::StripHeader,
timeout::{NewTimeout, ResponseTimeout, ResponseTimeoutError},
version::Version,
};
pub use http::{
header::{self, HeaderMap, HeaderName, HeaderValue},
@ -50,6 +48,7 @@ pub use http::{
pub use hyper::body::HttpBody;
pub use linkerd_http_box::{BoxBody, BoxRequest, BoxResponse, EraseResponse};
pub use linkerd_http_executor::TracingExecutor;
pub use linkerd_http_version::{self as version, Version};
#[derive(Clone, Debug)]
pub struct HeaderPair(pub HeaderName, pub HeaderValue);