@@ -116,6 +116,9 @@ pub enum Host {
116
116
/// omitted or the empty string.
117
117
/// * `connect_timeout` - The time limit in seconds applied to each socket-level connection attempt. Note that hostnames
118
118
/// can resolve to multiple IP addresses, and this limit is applied to each address. Defaults to no timeout.
119
+ /// * `tcp_user_timeout` - The time limit that transmitted data may remain unacknowledged before a connection is forcibly closed.
120
+ /// This is ignored for Unix domain socket connections. It is only supported on systems where TCP_USER_TIMEOUT is available
121
+ /// and will default to the system default if omitted or set to 0; on other systems, it has no effect.
119
122
/// * `keepalives` - Controls the use of TCP keepalive. A value of 0 disables keepalive and nonzero integers enable it.
120
123
/// This option is ignored when connecting with Unix sockets. Defaults to on.
121
124
/// * `keepalives_idle` - The number of seconds of inactivity after which a keepalive message is sent to the server.
@@ -183,6 +186,7 @@ pub struct Config {
183
186
pub ( crate ) host : Vec < Host > ,
184
187
pub ( crate ) port : Vec < u16 > ,
185
188
pub ( crate ) connect_timeout : Option < Duration > ,
189
+ pub ( crate ) tcp_user_timeout : Option < Duration > ,
186
190
pub ( crate ) keepalives : bool ,
187
191
pub ( crate ) keepalive_config : KeepaliveConfig ,
188
192
pub ( crate ) target_session_attrs : TargetSessionAttrs ,
@@ -217,6 +221,7 @@ impl Config {
217
221
host : vec ! [ ] ,
218
222
port : vec ! [ ] ,
219
223
connect_timeout : None ,
224
+ tcp_user_timeout : None ,
220
225
keepalives : true ,
221
226
keepalive_config,
222
227
target_session_attrs : TargetSessionAttrs :: Any ,
@@ -407,6 +412,21 @@ impl Config {
407
412
self . connect_timeout . as_ref ( )
408
413
}
409
414
415
+ /// Sets the TCP user timeout.
416
+ ///
417
+ /// This is ignored for Unix domain socket connections. It is only supported on systems where
418
+ /// TCP_USER_TIMEOUT is available and will default to the system default if omitted or set to 0;
419
+ /// on other systems, it has no effect.
420
+ pub fn tcp_user_timeout ( & mut self , tcp_user_timeout : Duration ) -> & mut Config {
421
+ self . tcp_user_timeout = Some ( tcp_user_timeout) ;
422
+ self
423
+ }
424
+
425
+ /// Gets the TCP user timeout, if one has been set with the
426
+ /// `user_timeout` method.
427
+ pub fn get_tcp_user_timeout ( & self ) -> Option < & Duration > {
428
+ self . tcp_user_timeout . as_ref ( )
429
+ }
410
430
/// Controls the use of TCP keepalive.
411
431
///
412
432
/// This is ignored for Unix domain socket connections. Defaults to `true`.
@@ -578,6 +598,14 @@ impl Config {
578
598
self . connect_timeout ( Duration :: from_secs ( timeout as u64 ) ) ;
579
599
}
580
600
}
601
+ "tcp_user_timeout" => {
602
+ let timeout = value
603
+ . parse :: < i64 > ( )
604
+ . map_err ( |_| Error :: config_parse ( Box :: new ( InvalidValue ( "tcp_user_timeout" ) ) ) ) ?;
605
+ if timeout > 0 {
606
+ self . tcp_user_timeout ( Duration :: from_secs ( timeout as u64 ) ) ;
607
+ }
608
+ }
581
609
"keepalives" => {
582
610
let keepalives = value
583
611
. parse :: < u64 > ( )
@@ -713,6 +741,7 @@ impl fmt::Debug for Config {
713
741
. field ( "host" , & self . host )
714
742
. field ( "port" , & self . port )
715
743
. field ( "connect_timeout" , & self . connect_timeout )
744
+ . field ( "tcp_user_timeout" , & self . tcp_user_timeout )
716
745
. field ( "keepalives" , & self . keepalives )
717
746
. field ( "keepalives_idle" , & self . keepalive_config . idle )
718
747
. field ( "keepalives_interval" , & self . keepalive_config . interval )
0 commit comments