Some more logs

This commit is contained in:
Roei Erez
2025-02-11 18:37:35 +02:00
parent fb953c3386
commit cb4da697f4
3 changed files with 9 additions and 3 deletions

View File

@@ -66,7 +66,7 @@ impl Persister {
}
let mut sync_trigger = None;
if sync_enabled {
let (events_notifier, _) = broadcast::channel::<()>(100);
let (events_notifier, _) = broadcast::channel::<()>(1);
sync_trigger = Some(events_notifier);
}
Ok(Persister {

View File

@@ -1,6 +1,7 @@
use std::collections::HashMap;
use anyhow::Result;
use log::info;
use rusqlite::{
named_params, Connection, OptionalExtension, Row, Statement, Transaction, TransactionBehavior,
};
@@ -499,6 +500,7 @@ impl Persister {
}
pub(crate) fn trigger_sync(&self) {
info!("realtime-sync: Triggering sync");
if let Some(sender) = self.sync_trigger.clone() {
_ = sender.send(());
}

View File

@@ -110,11 +110,12 @@ impl SyncService {
continue;
}
};
log::info!("realtime-sync: Starting sync service loop");
loop {
log::info!("realtime-sync: before tokio_select");
tokio::select! {
local_event = local_sync_trigger.recv() => {
log::info!("realtime-sync: Received local message");
match local_event {
Ok(_) => self.run_event_loop().await,
Err(err) => {
@@ -122,12 +123,15 @@ impl SyncService {
}
}
}
Some(msg) = remote_sync_trigger.next() => match msg {
Some(msg) = remote_sync_trigger.next() => {
log::info!("realtime-sync: Received remote message");
match msg {
Ok(_) => self.run_event_loop().await,
Err(err) => {
log::warn!("realtime-sync: Received status {} from remote, attempting to reconnect.", err.message());
break; // break the inner loop which will start the main loop by reconnecting
}
}
},
_ = shutdown.changed() => {
log::info!("realtime-sync: Received shutdown signal, exiting realtime sync service loop");