don't return on session error

This commit is contained in:
aniketfuryrocks 2023-03-21 22:00:18 +05:30
parent 8e5cf8a567
commit 19ab962a14
No known key found for this signature in database
GPG Key ID: FA6BFCFAA7D4B764
1 changed files with 8 additions and 3 deletions

View File

@ -1,6 +1,6 @@
use std::sync::Arc;
use std::{sync::Arc, time::Duration};
use anyhow::{bail, Context, Ok};
use anyhow::{bail, Context};
use log::{info, warn};
use postgres_native_tls::MakeTlsConnector;
@ -235,8 +235,13 @@ impl Postgres {
info!("Writing to postgres");
while let Some(msg) = recv.recv().await {
let Ok(session) = self.get_session().await else {
warn!("Unable to get postgres session. Retrying in 1000ms");
tokio::time::sleep(Duration::from_millis(1000));
continue;
};
MESSAGES_IN_POSTGRES_CHANNEL.dec();
let session = self.get_session().await?;
let Err(err) = (
match msg {