Skip to content

Commit 97b084f

Browse files
feat(server): allow configuration of max_local_error_reset_streams (#2437)
Squashed version of #2421 applied to `master`. Co-authored-by: alexanderrilee <[email protected]>
1 parent 36a8a8e commit 97b084f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

tonic/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async-trait = {version = "0.1.13", optional = true}
7575
# transport
7676
h2 = {version = "0.4", optional = true}
7777
hyper = {version = "1", features = ["http1", "http2"], optional = true}
78-
hyper-util = { version = "0.1.4", features = ["tokio"], optional = true }
78+
hyper-util = { version = "0.1.11", features = ["tokio"], optional = true }
7979
socket2 = { version = "0.6", optional = true, features = ["all"] }
8080
tokio = {version = "1", default-features = false, optional = true}
8181
tower = {version = "0.5", default-features = false, optional = true}

tonic/src/transport/server/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ pub struct Server<L = Identity> {
103103
http2_keepalive_timeout: Duration,
104104
http2_adaptive_window: Option<bool>,
105105
http2_max_pending_accept_reset_streams: Option<usize>,
106+
http2_max_local_error_reset_streams: Option<usize>,
106107
http2_max_header_list_size: Option<u32>,
107108
max_frame_size: Option<u32>,
108109
accept_http1: bool,
@@ -128,6 +129,7 @@ impl Default for Server<Identity> {
128129
http2_keepalive_timeout: DEFAULT_HTTP2_KEEPALIVE_TIMEOUT,
129130
http2_adaptive_window: None,
130131
http2_max_pending_accept_reset_streams: None,
132+
http2_max_local_error_reset_streams: None,
131133
http2_max_header_list_size: None,
132134
max_frame_size: None,
133135
accept_http1: false,
@@ -336,6 +338,17 @@ impl<L> Server<L> {
336338
}
337339
}
338340

341+
/// Configures the maximum number of local reset streams allowed before a GOAWAY will be sent.
342+
///
343+
/// This will default to whatever the default in hyper is.
344+
#[must_use]
345+
pub fn http2_max_local_error_reset_streams(self, max: Option<usize>) -> Self {
346+
Server {
347+
http2_max_local_error_reset_streams: max,
348+
..self
349+
}
350+
}
351+
339352
/// Set whether TCP keepalive messages are enabled on accepted connections.
340353
///
341354
/// If `None` is specified, keepalive is disabled, otherwise the duration
@@ -554,6 +567,7 @@ impl<L> Server<L> {
554567
http2_adaptive_window: self.http2_adaptive_window,
555568
http2_max_pending_accept_reset_streams: self.http2_max_pending_accept_reset_streams,
556569
http2_max_header_list_size: self.http2_max_header_list_size,
570+
http2_max_local_error_reset_streams: self.http2_max_local_error_reset_streams,
557571
max_frame_size: self.max_frame_size,
558572
accept_http1: self.accept_http1,
559573
max_connection_age: self.max_connection_age,
@@ -685,6 +699,7 @@ impl<L> Server<L> {
685699
let http2_keepalive_timeout = self.http2_keepalive_timeout;
686700
let http2_adaptive_window = self.http2_adaptive_window;
687701
let http2_max_pending_accept_reset_streams = self.http2_max_pending_accept_reset_streams;
702+
let http2_max_local_error_reset_streams = self.http2_max_local_error_reset_streams;
688703
let max_connection_age = self.max_connection_age;
689704

690705
let svc = self.service_builder.service(svc);
@@ -720,6 +735,7 @@ impl<L> Server<L> {
720735
.keep_alive_timeout(http2_keepalive_timeout)
721736
.adaptive_window(http2_adaptive_window.unwrap_or_default())
722737
.max_pending_accept_reset_streams(http2_max_pending_accept_reset_streams)
738+
.max_local_error_reset_streams(http2_max_local_error_reset_streams)
723739
.max_frame_size(max_frame_size);
724740

725741
if let Some(max_header_list_size) = max_header_list_size {

0 commit comments

Comments
 (0)