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 Jan 5, 2024
1 parent 177c1f3 commit 4792bb3
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 @@ -317,16 +317,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 @@ -338,16 +333,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 4792bb3

Please sign in to comment.