diff --git a/src/connection.rs b/src/connection.rs index bf53e3d..486e6ef 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -105,7 +105,6 @@ pub struct ConnectionManager { point_monitor_data: Arc>>, point_history_data: Arc>>>, point_write_target_cache: Arc>>, - pool: Option, event_manager: Option>, } @@ -155,10 +154,9 @@ impl ConnectionManager { } } - pub fn new_with_pool(pool: sqlx::PgPool) -> Self { + pub fn new() -> Self { Self { status: Arc::new(RwLock::new(HashMap::new())), - pool: Some(pool), point_monitor_data: Arc::new(RwLock::new(HashMap::new())), point_history_data: Arc::new(RwLock::new(HashMap::new())), point_write_target_cache: Arc::new(RwLock::new(HashMap::new())), @@ -562,28 +560,13 @@ impl ConnectionManager { } pub async fn get_session(&self, source_id: Uuid) -> Option> { - // comment fixed - { - let status = self.status.read().await; - if let Some(conn_status) = status.get(&source_id) { - if conn_status.is_connected { - return conn_status.session.clone(); - } + let status = self.status.read().await; + if let Some(conn_status) = status.get(&source_id) { + if conn_status.is_connected { + return conn_status.session.clone(); } } - - // comment fixed - if let Some(pool) = &self.pool { - if let Ok(()) = self.connect_from_source(pool, source_id).await { - // comment fixed - let status = self.status.read().await; - status.get(&source_id).and_then(|s| s.session.clone()) - } else { - None - } - } else { - None - } + None } pub async fn get_status(&self, source_id: Uuid) -> Option { diff --git a/src/main.rs b/src/main.rs index 79c9f63..2271e63 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ async fn main() { let config = AppConfig::from_env().expect("Failed to load configuration"); let pool = init_database(&config.database_url).await.expect("Failed to initialize database"); - let mut connection_manager = ConnectionManager::new_with_pool(pool.clone()); + let mut connection_manager = ConnectionManager::new(); let ws_manager = Arc::new(websocket::WebSocketManager::new()); let event_manager = Arc::new(EventManager::new( pool.clone(),