Skip to content

Commit

Permalink
tonic: add hyper's http2_max_pending_accept_reset_streams to server (
Browse files Browse the repository at this point in the history
  • Loading branch information
timvisee authored Aug 2, 2023
1 parent e1bac2b commit 6077896
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tonic/src/transport/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub struct Server<L = Identity> {
http2_keepalive_interval: Option<Duration>,
http2_keepalive_timeout: Option<Duration>,
http2_adaptive_window: Option<bool>,
http2_max_pending_accept_reset_streams: Option<usize>,
max_frame_size: Option<u32>,
accept_http1: bool,
service_builder: ServiceBuilder<L>,
Expand All @@ -112,6 +113,7 @@ impl Default for Server<Identity> {
http2_keepalive_interval: None,
http2_keepalive_timeout: None,
http2_adaptive_window: None,
http2_max_pending_accept_reset_streams: None,
max_frame_size: None,
accept_http1: false,
service_builder: Default::default(),
Expand Down Expand Up @@ -271,6 +273,19 @@ impl<L> Server<L> {
}
}

/// Configures the maximum number of pending reset streams allowed before a GOAWAY will be sent.
///
/// This will default to whatever the default in h2 is. As of v0.3.17, it is 20.
///
/// See <https://github.com/hyperium/hyper/issues/2877> for more information.
#[must_use]
pub fn http2_max_pending_accept_reset_streams(self, max: Option<usize>) -> Self {
Server {
http2_max_pending_accept_reset_streams: max,
..self
}
}

/// Set whether TCP keepalive messages are enabled on accepted connections.
///
/// If `None` is specified, keepalive is disabled, otherwise the duration
Expand Down Expand Up @@ -453,6 +468,7 @@ impl<L> Server<L> {
http2_keepalive_interval: self.http2_keepalive_interval,
http2_keepalive_timeout: self.http2_keepalive_timeout,
http2_adaptive_window: self.http2_adaptive_window,
http2_max_pending_accept_reset_streams: self.http2_max_pending_accept_reset_streams,
max_frame_size: self.max_frame_size,
accept_http1: self.accept_http1,
}
Expand Down Expand Up @@ -491,6 +507,7 @@ impl<L> Server<L> {
.http2_keepalive_timeout
.unwrap_or_else(|| Duration::new(DEFAULT_HTTP2_KEEPALIVE_TIMEOUT_SECS, 0));
let http2_adaptive_window = self.http2_adaptive_window;
let http2_max_pending_accept_reset_streams = self.http2_max_pending_accept_reset_streams;

let svc = self.service_builder.service(svc);

Expand All @@ -513,6 +530,7 @@ impl<L> Server<L> {
.http2_keep_alive_interval(http2_keepalive_interval)
.http2_keep_alive_timeout(http2_keepalive_timeout)
.http2_adaptive_window(http2_adaptive_window.unwrap_or_default())
.http2_max_pending_accept_reset_streams(http2_max_pending_accept_reset_streams)
.http2_max_frame_size(max_frame_size);

if let Some(signal) = signal {
Expand Down

0 comments on commit 6077896

Please sign in to comment.