Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tonic): expose setting for http2_adaptive_window #657

Merged
merged 1 commit into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tonic/src/transport/channel/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct Endpoint {
pub(crate) http2_keep_alive_interval: Option<Duration>,
pub(crate) http2_keep_alive_timeout: Option<Duration>,
pub(crate) http2_keep_alive_while_idle: Option<bool>,
pub(crate) http2_adaptive_window: Option<bool>,
}

impl Endpoint {
Expand Down Expand Up @@ -231,6 +232,14 @@ impl Endpoint {
}
}

/// Sets whether to use an adaptive flow control. Uses `hyper`'s default otherwise.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to the hyper setting?

pub fn http2_adaptive_window(self, enabled: bool) -> Self {
Endpoint {
http2_adaptive_window: Some(enabled),
..self
}
}

/// Create a channel from this config.
pub async fn connect(&self) -> Result<Channel, Error> {
let mut http = hyper::client::connect::HttpConnector::new();
Expand Down Expand Up @@ -319,6 +328,7 @@ impl From<Uri> for Endpoint {
http2_keep_alive_interval: None,
http2_keep_alive_timeout: None,
http2_keep_alive_while_idle: None,
http2_adaptive_window: None,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions tonic/src/transport/service/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl Connection {
settings.http2_keep_alive_while_idle(val);
}

if let Some(val) = endpoint.http2_adaptive_window {
settings.http2_adaptive_window(val);
}

let stack = ServiceBuilder::new()
.layer_fn(|s| AddOrigin::new(s, endpoint.uri.clone()))
.layer_fn(|s| UserAgent::new(s, endpoint.user_agent.clone()))
Expand Down