File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
grpc/src/client/transport Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 11use crate :: { rt:: Runtime , service:: Service } ;
2+ use std:: time:: Instant ;
23use std:: { sync:: Arc , time:: Duration } ;
34
45mod registry;
@@ -34,7 +35,7 @@ pub(crate) struct TransportOptions {
3435 pub rate_limit : Option < ( u64 , Duration ) > ,
3536 pub tcp_keepalive : Option < Duration > ,
3637 pub tcp_nodelay : bool ,
37- pub connect_timeout : Option < Duration > ,
38+ pub connect_deadline : Option < Instant > ,
3839}
3940
4041#[ async_trait]
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ use http::Uri;
1717use hyper:: client:: conn:: http2:: Builder ;
1818use hyper:: client:: conn:: http2:: SendRequest ;
1919use std:: any:: Any ;
20+ use std:: time:: Instant ;
2021use std:: {
2122 error:: Error ,
2223 future:: Future ,
@@ -191,7 +192,8 @@ impl Transport for TransportBuilder {
191192 keepalive : opts. tcp_keepalive ,
192193 } ,
193194 ) ;
194- let tcp_stream = if let Some ( timeout) = opts. connect_timeout {
195+ let tcp_stream = if let Some ( deadline) = opts. connect_deadline {
196+ let timeout = deadline. saturating_duration_since ( Instant :: now ( ) ) ;
195197 tokio:: select! {
196198 _ = runtime. sleep( timeout) => {
197199 return Err ( "timed out waiting for TCP stream to connect" . to_string( ) )
You can’t perform that action at this time.
0 commit comments