Skip to content

Commit

Permalink
chore(transport): Use hyper timeout feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Sep 3, 2023
1 parent 79246e7 commit 6cea731
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions tonic/src/transport/channel/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,15 @@ impl Endpoint {
http.enforce_http(false);
http.set_nodelay(self.tcp_nodelay);
http.set_keepalive(self.tcp_keepalive);
http.set_connect_timeout(self.connect_timeout);

#[cfg(feature = "tls")]
let connector = service::connector(http, self.tls.clone());

#[cfg(not(feature = "tls"))]
let connector = service::connector(http);

if let Some(connect_timeout) = self.connect_timeout {
let mut connector = hyper_timeout::TimeoutConnector::new(connector);
connector.set_connect_timeout(Some(connect_timeout));
Channel::connect(connector, self.clone()).await
} else {
Channel::connect(connector, self.clone()).await
}
Channel::connect(connector, self.clone()).await
}

/// Create a channel from this config.
Expand All @@ -332,20 +327,15 @@ impl Endpoint {
http.enforce_http(false);
http.set_nodelay(self.tcp_nodelay);
http.set_keepalive(self.tcp_keepalive);
http.set_connect_timeout(self.connect_timeout);

#[cfg(feature = "tls")]
let connector = service::connector(http, self.tls.clone());

#[cfg(not(feature = "tls"))]
let connector = service::connector(http);

if let Some(connect_timeout) = self.connect_timeout {
let mut connector = hyper_timeout::TimeoutConnector::new(connector);
connector.set_connect_timeout(Some(connect_timeout));
Channel::new(connector, self.clone())
} else {
Channel::new(connector, self.clone())
}
Channel::new(connector, self.clone())
}

/// Connect with a custom connector.
Expand Down

0 comments on commit 6cea731

Please sign in to comment.