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:
Prajjwal Kumar
2023-04-24 13:08:00 +05:30
committed by GitHub
parent 85c7629061
commit 13185999d5
21 changed files with 166 additions and 74 deletions

View File

@ -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;
}
}
}