mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat: add unresponsive timeout for fred (#3369)
This commit is contained in:
@ -132,6 +132,11 @@ impl RedisConnectionPool {
|
||||
},
|
||||
};
|
||||
|
||||
let connection_config = fred::types::ConnectionConfig {
|
||||
unresponsive_timeout: std::time::Duration::from_secs(conf.unresponsive_timeout),
|
||||
..fred::types::ConnectionConfig::default()
|
||||
};
|
||||
|
||||
if !conf.use_legacy_version {
|
||||
config.version = fred::types::RespVersion::RESP3;
|
||||
}
|
||||
@ -151,7 +156,7 @@ impl RedisConnectionPool {
|
||||
let pool = fred::prelude::RedisPool::new(
|
||||
config,
|
||||
Some(perf),
|
||||
None,
|
||||
Some(connection_config),
|
||||
Some(reconnect_policy),
|
||||
conf.pool_size,
|
||||
)
|
||||
@ -201,6 +206,15 @@ impl RedisConnectionPool {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn on_unresponsive(&self) {
|
||||
let _ = self.pool.clients().iter().map(|client| {
|
||||
client.on_unresponsive(|server| {
|
||||
logger::warn!(redis_server =?server.host, "Redis server is unresponsive");
|
||||
Ok(())
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
struct RedisConfig {
|
||||
|
||||
Reference in New Issue
Block a user