Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(http): split params types into a dedicated http-h2 crate #2936

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,10 @@ dependencies = [
"linkerd-error",
]

[[package]]
name = "linkerd-http-h2"
version = "0.1.0"

[[package]]
name = "linkerd-http-metrics"
version = "0.1.0"
Expand Down Expand Up @@ -1854,6 +1858,7 @@ dependencies = [
"linkerd-error",
"linkerd-http-box",
"linkerd-http-classify",
"linkerd-http-h2",
"linkerd-io",
"linkerd-proxy-balance",
"linkerd-stack",
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"linkerd/http/access-log",
"linkerd/http/box",
"linkerd/http/classify",
"linkerd/http/h2",
"linkerd/http/metrics",
"linkerd/http/retry",
"linkerd/http/route",
Expand Down Expand Up @@ -77,6 +78,7 @@ members = [
"opencensus-proto",
"spiffe-proto",
"tools",
"linkerd/http/h2",
]

[profile.release]
Expand Down
6 changes: 6 additions & 0 deletions linkerd/http/h2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "linkerd-http-h2"
version = "0.1.0"
edition = "2021"
publish = false
description = "HTTP/2-specific configuration types"
47 changes: 47 additions & 0 deletions linkerd/http/h2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use std::time::Duration;

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct ServerParams {
pub flow_control: Option<FlowControl>,
pub keep_alive: Option<KeepAlive>,
pub max_concurrent_streams: Option<u32>,

// Internals
pub max_frame_size: Option<u32>,
pub max_header_list_size: Option<u32>,
pub max_pending_accept_reset_streams: Option<usize>,
pub max_send_buf_size: Option<usize>,
}

#[derive(Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct ClientParams {
pub flow_control: Option<FlowControl>,
pub keep_alive: Option<ClientKeepAlive>,

// Internals
pub max_concurrent_reset_streams: Option<usize>,
pub max_frame_size: Option<u32>,
pub max_send_buf_size: Option<usize>,
}

#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct KeepAlive {
pub interval: Duration,
pub timeout: Duration,
}

#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, Hash)]
pub struct ClientKeepAlive {
pub interval: Duration,
pub timeout: Duration,
pub while_idle: bool,
}

#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum FlowControl {
Adaptive,
Fixed {
initial_stream_window_size: u32,
initial_connection_window_size: u32,
},
}
1 change: 1 addition & 0 deletions linkerd/proxy/http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ linkerd-detect = { path = "../../detect" }
linkerd-duplex = { path = "../../duplex" }
linkerd-error = { path = "../../error" }
linkerd-http-box = { path = "../../http/box" }
linkerd-http-h2 = { path = "../../http/h2" }
linkerd-http-classify = { path = "../../http/classify" }
linkerd-io = { path = "../../io" }
linkerd-proxy-balance = { path = "../balance" }
Expand Down
49 changes: 2 additions & 47 deletions linkerd/proxy/http/src/h2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::executor::TracingExecutor;
use futures::prelude::*;
pub use h2::{Error as H2Error, Reason};
use hyper::{
body::HttpBody,
client::conn::{self, SendRequest},
Expand All @@ -11,56 +10,12 @@ use std::{
marker::PhantomData,
pin::Pin,
task::{Context, Poll},
time::Duration,
};
use tracing::instrument::Instrument;
use tracing::{debug, debug_span, trace_span};

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct ServerParams {
pub flow_control: Option<FlowControl>,
pub keep_alive: Option<KeepAlive>,
pub max_concurrent_streams: Option<u32>,

// Internals
pub max_frame_size: Option<u32>,
pub max_header_list_size: Option<u32>,
pub max_pending_accept_reset_streams: Option<usize>,
pub max_send_buf_size: Option<usize>,
}

#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct ClientParams {
pub flow_control: Option<FlowControl>,
pub keep_alive: Option<ClientKeepAlive>,

// Internals
pub max_concurrent_reset_streams: Option<usize>,
pub max_frame_size: Option<u32>,
pub max_send_buf_size: Option<usize>,
}

#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct KeepAlive {
pub interval: Duration,
pub timeout: Duration,
}

#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct ClientKeepAlive {
pub interval: Duration,
pub timeout: Duration,
pub while_idle: bool,
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum FlowControl {
Adaptive,
Fixed {
initial_stream_window_size: u32,
initial_connection_window_size: u32,
},
}
pub use h2::{Error as H2Error, Reason};
pub use linkerd_http_h2::{ClientKeepAlive, ClientParams, FlowControl, KeepAlive, ServerParams};

#[derive(Debug)]
pub struct Connect<C, B> {
Expand Down
Loading