Skip to content

Commit

Permalink
chore(transport): Use hyper timeout feature (#1497)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored May 21, 2024
1 parent 7551d5d commit f88eb79
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 @@ -337,16 +337,11 @@ 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);

let connector = self.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 @@ -358,16 +353,11 @@ 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);

let connector = self.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 f88eb79

Please sign in to comment.