feat(transport): Expose hyper's H2 adaptive window on server (#1071)
Co-authored-by: Adam Chalmers <[email protected]>
This commit is contained in:
co-authored by
Adam Chalmers
parent
2a83f8ba1a
commit
919d28b2b9
@@ -90,6 +90,7 @@ pub struct Server<L = Identity> {
|
|||||||
tcp_nodelay: bool,
|
tcp_nodelay: bool,
|
||||||
http2_keepalive_interval: Option<Duration>,
|
http2_keepalive_interval: Option<Duration>,
|
||||||
http2_keepalive_timeout: Option<Duration>,
|
http2_keepalive_timeout: Option<Duration>,
|
||||||
|
http2_adaptive_window: Option<bool>,
|
||||||
max_frame_size: Option<u32>,
|
max_frame_size: Option<u32>,
|
||||||
accept_http1: bool,
|
accept_http1: bool,
|
||||||
service_builder: ServiceBuilder<L>,
|
service_builder: ServiceBuilder<L>,
|
||||||
@@ -110,6 +111,7 @@ impl Default for Server<Identity> {
|
|||||||
tcp_nodelay: false,
|
tcp_nodelay: false,
|
||||||
http2_keepalive_interval: None,
|
http2_keepalive_interval: None,
|
||||||
http2_keepalive_timeout: None,
|
http2_keepalive_timeout: None,
|
||||||
|
http2_adaptive_window: None,
|
||||||
max_frame_size: None,
|
max_frame_size: None,
|
||||||
accept_http1: false,
|
accept_http1: false,
|
||||||
service_builder: Default::default(),
|
service_builder: Default::default(),
|
||||||
@@ -258,6 +260,17 @@ impl<L> Server<L> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets whether to use an adaptive flow control. Defaults to false.
|
||||||
|
/// Enabling this will override the limits set in http2_initial_stream_window_size and
|
||||||
|
/// http2_initial_connection_window_size.
|
||||||
|
#[must_use]
|
||||||
|
pub fn http2_adaptive_window(self, enabled: Option<bool>) -> Self {
|
||||||
|
Server {
|
||||||
|
http2_adaptive_window: enabled,
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Set whether TCP keepalive messages are enabled on accepted connections.
|
/// Set whether TCP keepalive messages are enabled on accepted connections.
|
||||||
///
|
///
|
||||||
/// If `None` is specified, keepalive is disabled, otherwise the duration
|
/// If `None` is specified, keepalive is disabled, otherwise the duration
|
||||||
@@ -439,6 +452,7 @@ impl<L> Server<L> {
|
|||||||
tcp_nodelay: self.tcp_nodelay,
|
tcp_nodelay: self.tcp_nodelay,
|
||||||
http2_keepalive_interval: self.http2_keepalive_interval,
|
http2_keepalive_interval: self.http2_keepalive_interval,
|
||||||
http2_keepalive_timeout: self.http2_keepalive_timeout,
|
http2_keepalive_timeout: self.http2_keepalive_timeout,
|
||||||
|
http2_adaptive_window: self.http2_adaptive_window,
|
||||||
max_frame_size: self.max_frame_size,
|
max_frame_size: self.max_frame_size,
|
||||||
accept_http1: self.accept_http1,
|
accept_http1: self.accept_http1,
|
||||||
}
|
}
|
||||||
@@ -476,6 +490,7 @@ impl<L> Server<L> {
|
|||||||
let http2_keepalive_timeout = self
|
let http2_keepalive_timeout = self
|
||||||
.http2_keepalive_timeout
|
.http2_keepalive_timeout
|
||||||
.unwrap_or_else(|| Duration::new(DEFAULT_HTTP2_KEEPALIVE_TIMEOUT_SECS, 0));
|
.unwrap_or_else(|| Duration::new(DEFAULT_HTTP2_KEEPALIVE_TIMEOUT_SECS, 0));
|
||||||
|
let http2_adaptive_window = self.http2_adaptive_window;
|
||||||
|
|
||||||
let svc = self.service_builder.service(svc);
|
let svc = self.service_builder.service(svc);
|
||||||
|
|
||||||
@@ -497,6 +512,7 @@ impl<L> Server<L> {
|
|||||||
.http2_max_concurrent_streams(max_concurrent_streams)
|
.http2_max_concurrent_streams(max_concurrent_streams)
|
||||||
.http2_keep_alive_interval(http2_keepalive_interval)
|
.http2_keep_alive_interval(http2_keepalive_interval)
|
||||||
.http2_keep_alive_timeout(http2_keepalive_timeout)
|
.http2_keep_alive_timeout(http2_keepalive_timeout)
|
||||||
|
.http2_adaptive_window(http2_adaptive_window.unwrap_or_default())
|
||||||
.http2_max_frame_size(max_frame_size);
|
.http2_max_frame_size(max_frame_size);
|
||||||
|
|
||||||
if let Some(signal) = signal {
|
if let Some(signal) = signal {
|
||||||
|
|||||||
Reference in New Issue
Block a user