Skip to content

Commit da17a73

Browse files
allow configuration of max_local_error_reset_streams
1 parent b303caa commit da17a73

File tree

1 file changed

+16
-0
lines changed
  • tonic/src/transport/server

1 file changed

+16
-0
lines changed

tonic/src/transport/server/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub struct Server<L = Identity> {
9999
http2_keepalive_timeout: Duration,
100100
http2_adaptive_window: Option<bool>,
101101
http2_max_pending_accept_reset_streams: Option<usize>,
102+
http2_max_local_error_reset_streams: Option<usize>,
102103
http2_max_header_list_size: Option<u32>,
103104
max_frame_size: Option<u32>,
104105
accept_http1: bool,
@@ -123,6 +124,7 @@ impl Default for Server<Identity> {
123124
http2_keepalive_timeout: DEFAULT_HTTP2_KEEPALIVE_TIMEOUT,
124125
http2_adaptive_window: None,
125126
http2_max_pending_accept_reset_streams: None,
127+
http2_max_local_error_reset_streams: None,
126128
http2_max_header_list_size: None,
127129
max_frame_size: None,
128130
accept_http1: false,
@@ -314,6 +316,17 @@ impl<L> Server<L> {
314316
}
315317
}
316318

319+
/// Configures the maximum number of local reset streams allowed before a GOAWAY will be sent.
320+
///
321+
/// This will default to whatever the default in hyper is. As of v1.7.0, it is 1024.
322+
#[must_use]
323+
pub fn http2_max_local_error_reset_streams(self, max: Option<usize>) -> Self {
324+
Server {
325+
http2_max_local_error_reset_streams: max,
326+
..self
327+
}
328+
}
329+
317330
/// Set whether TCP keepalive messages are enabled on accepted connections.
318331
///
319332
/// If `None` is specified, keepalive is disabled, otherwise the duration
@@ -527,6 +540,7 @@ impl<L> Server<L> {
527540
http2_adaptive_window: self.http2_adaptive_window,
528541
http2_max_pending_accept_reset_streams: self.http2_max_pending_accept_reset_streams,
529542
http2_max_header_list_size: self.http2_max_header_list_size,
543+
http2_max_local_error_reset_streams: self.http2_max_local_error_reset_streams,
530544
max_frame_size: self.max_frame_size,
531545
accept_http1: self.accept_http1,
532546
max_connection_age: self.max_connection_age,
@@ -655,6 +669,7 @@ impl<L> Server<L> {
655669
let http2_keepalive_timeout = self.http2_keepalive_timeout;
656670
let http2_adaptive_window = self.http2_adaptive_window;
657671
let http2_max_pending_accept_reset_streams = self.http2_max_pending_accept_reset_streams;
672+
let http2_max_local_error_reset_streams = self.http2_max_local_error_reset_streams;
658673
let max_connection_age = self.max_connection_age;
659674

660675
let svc = self.service_builder.service(svc);
@@ -689,6 +704,7 @@ impl<L> Server<L> {
689704
.keep_alive_timeout(http2_keepalive_timeout)
690705
.adaptive_window(http2_adaptive_window.unwrap_or_default())
691706
.max_pending_accept_reset_streams(http2_max_pending_accept_reset_streams)
707+
.max_local_error_reset_streams(http2_max_local_error_reset_streams)
692708
.max_frame_size(max_frame_size);
693709

694710
if let Some(max_header_list_size) = max_header_list_size {

0 commit comments

Comments
 (0)