@@ -197,6 +197,9 @@ pub struct General {
197
197
#[ serde( default = "General::default_ban_time" ) ]
198
198
pub ban_time : i64 ,
199
199
200
+ #[ serde( default = "General::default_idle_client_in_transaction_timeout" ) ]
201
+ pub idle_client_in_transaction_timeout : u64 ,
202
+
200
203
#[ serde( default = "General::default_worker_threads" ) ]
201
204
pub worker_threads : usize ,
202
205
@@ -260,6 +263,10 @@ impl General {
260
263
pub fn default_worker_threads ( ) -> usize {
261
264
4
262
265
}
266
+
267
+ pub fn default_idle_client_in_transaction_timeout ( ) -> u64 {
268
+ 0
269
+ }
263
270
}
264
271
265
272
impl Default for General {
@@ -276,6 +283,7 @@ impl Default for General {
276
283
healthcheck_delay : Self :: default_healthcheck_delay ( ) ,
277
284
ban_time : Self :: default_ban_time ( ) ,
278
285
worker_threads : Self :: default_worker_threads ( ) ,
286
+ idle_client_in_transaction_timeout : Self :: default_idle_client_in_transaction_timeout ( ) ,
279
287
tcp_keepalives_idle : Self :: default_tcp_keepalives_idle ( ) ,
280
288
tcp_keepalives_count : Self :: default_tcp_keepalives_count ( ) ,
281
289
tcp_keepalives_interval : Self :: default_tcp_keepalives_interval ( ) ,
@@ -655,6 +663,13 @@ impl From<&Config> for std::collections::HashMap<String, String> {
655
663
config. general. healthcheck_delay. to_string( ) ,
656
664
) ,
657
665
( "ban_time" . to_string( ) , config. general. ban_time. to_string( ) ) ,
666
+ (
667
+ "idle_client_in_transaction_timeout" . to_string( ) ,
668
+ config
669
+ . general
670
+ . idle_client_in_transaction_timeout
671
+ . to_string( ) ,
672
+ ) ,
658
673
] ;
659
674
660
675
r. append ( & mut static_settings) ;
@@ -666,6 +681,10 @@ impl Config {
666
681
/// Print current configuration.
667
682
pub fn show ( & self ) {
668
683
info ! ( "Ban time: {}s" , self . general. ban_time) ;
684
+ info ! (
685
+ "Idle client in transaction timeout: {}ms" ,
686
+ self . general. idle_client_in_transaction_timeout
687
+ ) ;
669
688
info ! ( "Worker threads: {}" , self . general. worker_threads) ;
670
689
info ! (
671
690
"Healthcheck timeout: {}ms" ,
@@ -819,6 +838,12 @@ pub fn get_config() -> Config {
819
838
( * ( * CONFIG . load ( ) ) ) . clone ( )
820
839
}
821
840
841
+ pub fn get_idle_client_in_transaction_timeout ( ) -> u64 {
842
+ ( * ( * CONFIG . load ( ) ) )
843
+ . general
844
+ . idle_client_in_transaction_timeout
845
+ }
846
+
822
847
/// Parse the configuration file located at the path.
823
848
pub async fn parse ( path : & str ) -> Result < ( ) , Error > {
824
849
let mut contents = String :: new ( ) ;
@@ -889,6 +914,7 @@ mod test {
889
914
assert_eq ! ( get_config( ) . path, "pgcat.toml" . to_string( ) ) ;
890
915
891
916
assert_eq ! ( get_config( ) . general. ban_time, 60 ) ;
917
+ assert_eq ! ( get_config( ) . general. idle_client_in_transaction_timeout, 0 ) ;
892
918
assert_eq ! ( get_config( ) . general. idle_timeout, 30000 ) ;
893
919
assert_eq ! ( get_config( ) . pools. len( ) , 2 ) ;
894
920
assert_eq ! ( get_config( ) . pools[ "sharded_db" ] . shards. len( ) , 3 ) ;
0 commit comments