postgres channel don't break

This commit is contained in:
aniketfuryrocks 2023-03-21 22:05:14 +05:30
parent 6ab141bb7f
commit f98c8f2e4c
No known key found for this signature in database
GPG Key ID: FA6BFCFAA7D4B764
1 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,4 @@
use std::sync::Arc;
use std::{sync::Arc, time::Duration};
use anyhow::{bail, Context};
@ -327,7 +327,12 @@ impl Postgres {
loop {
let msg = recv.try_recv();
let session = self.get_session().await?;
let Ok(session) = self.get_session().await else {
const TIME_OUT:Duration = Duration::from_millis(1000);
warn!("Unable to get postgres session. Retrying in {TIME_OUT:?}");
tokio::time::sleep(TIME_OUT).await;
continue;
};
match msg {
Ok(msg) => {