Skip to content

Commit 8cde9e1

Browse files
committed
chore(transport): Use hyper timeout feature
1 parent f1a5b91 commit 8cde9e1

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

tonic/src/transport/channel/endpoint.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,11 @@ impl Endpoint {
337337
http.enforce_http(false);
338338
http.set_nodelay(self.tcp_nodelay);
339339
http.set_keepalive(self.tcp_keepalive);
340+
http.set_connect_timeout(self.connect_timeout);
340341

341342
let connector = self.connector(http);
342343

343-
if let Some(connect_timeout) = self.connect_timeout {
344-
let mut connector = hyper_timeout::TimeoutConnector::new(connector);
345-
connector.set_connect_timeout(Some(connect_timeout));
346-
Channel::connect(connector, self.clone()).await
347-
} else {
348-
Channel::connect(connector, self.clone()).await
349-
}
344+
Channel::connect(connector, self.clone()).await
350345
}
351346

352347
/// Create a channel from this config.
@@ -358,16 +353,11 @@ impl Endpoint {
358353
http.enforce_http(false);
359354
http.set_nodelay(self.tcp_nodelay);
360355
http.set_keepalive(self.tcp_keepalive);
356+
http.set_connect_timeout(self.connect_timeout);
361357

362358
let connector = self.connector(http);
363359

364-
if let Some(connect_timeout) = self.connect_timeout {
365-
let mut connector = hyper_timeout::TimeoutConnector::new(connector);
366-
connector.set_connect_timeout(Some(connect_timeout));
367-
Channel::new(connector, self.clone())
368-
} else {
369-
Channel::new(connector, self.clone())
370-
}
360+
Channel::new(connector, self.clone())
371361
}
372362

373363
/// Connect with a custom connector.

0 commit comments

Comments
 (0)