From b25bc4085157e05343566f93d36fd810b96a4835 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 8 Jun 2025 20:20:13 +0100 Subject: [PATCH] Fix PR diff --- backend/config-e2e.yml | 1 - backend/sync_server/src/app_state/cursors.rs | 13 ++++--------- .../sync_server/src/config/database_config.rs | 16 +--------------- backend/sync_server/src/consts.rs | 1 - 4 files changed, 5 insertions(+), 26 deletions(-) diff --git a/backend/config-e2e.yml b/backend/config-e2e.yml index 5018c716..5f2346d6 100644 --- a/backend/config-e2e.yml +++ b/backend/config-e2e.yml @@ -2,7 +2,6 @@ database: databases_directory_path: databases max_connections_per_vault: 12 cursor_timeout_seconds: 60 - cursor_broadcast_interval_seconds: 1 server: host: 0.0.0.0 port: 3000 diff --git a/backend/sync_server/src/app_state/cursors.rs b/backend/sync_server/src/app_state/cursors.rs index 6b8a8605..245109c2 100644 --- a/backend/sync_server/src/app_state/cursors.rs +++ b/backend/sync_server/src/app_state/cursors.rs @@ -50,7 +50,6 @@ impl Cursors { })); drop(vault_to_cursors); // Explicitly drop the lock before broadcasting to avoid deadlock - self.broadcast_cursors().await; } @@ -70,17 +69,13 @@ impl Cursors { pub fn start_background_task(self) { tokio::spawn(async move { - self.run_backround_task().await; + loop { + self.remove_expired_cursors().await; + tokio::time::sleep(Duration::from_secs(1)).await; + } }); } - async fn run_backround_task(&self) { - loop { - self.remove_expired_cursors().await; - tokio::time::sleep(self.config.cursor_broadcast_interval).await; - } - } - async fn remove_expired_cursors(&self) { let mut vault_to_cursors = self.vault_to_cursors.lock().await; diff --git a/backend/sync_server/src/config/database_config.rs b/backend/sync_server/src/config/database_config.rs index 118d805e..f1c92d9d 100644 --- a/backend/sync_server/src/config/database_config.rs +++ b/backend/sync_server/src/config/database_config.rs @@ -5,8 +5,7 @@ use serde::{Deserialize, Serialize}; use serde_with::serde_as; use crate::consts::{ - DEFAULT_CURSOR_BROADCAST_INTERVAL, DEFAULT_CURSOR_TIMEOUT, DEFAULT_DATABASES_DIRECTORY_PATH, - DEFAULT_MAX_CONNECTIONS_PER_VAULT, + DEFAULT_CURSOR_TIMEOUT, DEFAULT_DATABASES_DIRECTORY_PATH, DEFAULT_MAX_CONNECTIONS_PER_VAULT, }; #[serde_with::serde_as] @@ -21,13 +20,6 @@ pub struct DatabaseConfig { #[serde(default = "default_cursor_timeout", rename = "cursor_timeout_seconds")] #[serde_as(as = "serde_with::DurationSeconds")] pub cursor_timeout: Duration, - - #[serde( - default = "default_cursor_broadcast_interval", - rename = "cursor_broadcast_interval_seconds" - )] - #[serde_as(as = "serde_with::DurationSeconds")] - pub cursor_broadcast_interval: Duration, } fn default_databases_directory_path() -> PathBuf { @@ -45,18 +37,12 @@ fn default_cursor_timeout() -> Duration { DEFAULT_CURSOR_TIMEOUT } -fn default_cursor_broadcast_interval() -> Duration { - debug!("Using default cursor broadcast interval: {DEFAULT_CURSOR_BROADCAST_INTERVAL:?}"); - DEFAULT_CURSOR_BROADCAST_INTERVAL -} - impl Default for DatabaseConfig { fn default() -> Self { Self { databases_directory_path: default_databases_directory_path(), max_connections_per_vault: default_max_connections_per_vault(), cursor_timeout: default_cursor_timeout(), - cursor_broadcast_interval: default_cursor_broadcast_interval(), } } } diff --git a/backend/sync_server/src/consts.rs b/backend/sync_server/src/consts.rs index 01927335..df5a2844 100644 --- a/backend/sync_server/src/consts.rs +++ b/backend/sync_server/src/consts.rs @@ -5,7 +5,6 @@ pub const DEFAULT_CONFIG_PATH: &str = "config.yml"; pub const DEFAULT_DATABASES_DIRECTORY_PATH: &str = "databases"; pub const DEFAULT_MAX_CONNECTIONS_PER_VAULT: u32 = 12; pub const DEFAULT_CURSOR_TIMEOUT: Duration = Duration::from_secs(60); -pub const DEFAULT_CURSOR_BROADCAST_INTERVAL: Duration = Duration::from_secs(1); pub const DEFAULT_HOST: &str = "127.0.0.1"; pub const DEFAULT_PORT: u16 = 3000;