From c496843b032193fb83b3b12b0be413e1361d5b1d Mon Sep 17 00:00:00 2001 From: timvisee Date: Fri, 19 May 2023 12:57:48 +0200 Subject: [PATCH] tonic: add hyper's `http2_max_pending_accept_reset_streams` to server --- tonic/src/transport/server/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tonic/src/transport/server/mod.rs b/tonic/src/transport/server/mod.rs index 37b8c2b35..071fc9ed7 100644 --- a/tonic/src/transport/server/mod.rs +++ b/tonic/src/transport/server/mod.rs @@ -91,6 +91,7 @@ pub struct Server { http2_keepalive_interval: Option, http2_keepalive_timeout: Option, http2_adaptive_window: Option, + http2_max_pending_accept_reset_streams: Option, max_frame_size: Option, accept_http1: bool, service_builder: ServiceBuilder, @@ -112,6 +113,7 @@ impl Default for Server { 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(), @@ -271,6 +273,19 @@ impl Server { } } + /// 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 for more information. + #[must_use] + pub fn http2_max_pending_accept_reset_streams(self, max: Option) -> 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 @@ -453,6 +468,7 @@ impl Server { 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, } @@ -491,6 +507,7 @@ impl Server { .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); @@ -513,6 +530,7 @@ impl Server { .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 {