mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(Core): gracefully shutdown router/scheduler if Redis is unavailable (#891)
Co-authored-by: prajjwal kumar <prajjwal.kumar@prajjwalkumar-DWKH9NPY4R.local> Co-authored-by: Nishant Joshi <nishant.joshi@juspay.in> Co-authored-by: Arun Raj M <jarnura47@gmail.com>
This commit is contained in:
@ -138,12 +138,18 @@ impl RedisConnectionPool {
|
||||
};
|
||||
}
|
||||
}
|
||||
pub async fn on_error(&self) {
|
||||
|
||||
pub async fn on_error(&self, tx: tokio::sync::oneshot::Sender<()>) {
|
||||
while let Ok(redis_error) = self.pool.on_error().recv().await {
|
||||
logger::error!(?redis_error, "Redis protocol or connection error");
|
||||
logger::error!("current state: {:#?}", self.pool.state());
|
||||
if self.pool.state() == fred::types::ClientState::Disconnected {
|
||||
if tx.send(()).is_err() {
|
||||
logger::error!("The redis shutdown signal sender failed to signal");
|
||||
}
|
||||
self.is_redis_available
|
||||
.store(false, atomic::Ordering::SeqCst);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user