优化连接流程:connect_from_source自动处理订阅,简化main.rs

This commit is contained in:
caoqianming 2026-03-05 11:18:30 +08:00
parent a2217a991c
commit 494cf1d656
2 changed files with 9 additions and 11 deletions

View File

@ -395,7 +395,13 @@ impl ConnectionManager {
source.username.as_deref(), source.username.as_deref(),
source.password.as_deref(), source.password.as_deref(),
) )
.await .await?;
// Subscribe to points for this source
self.subscribe_points_from_source(source_id, None, pool)
.await?;
Ok(())
} }
pub async fn connect( pub async fn connect(

View File

@ -62,16 +62,8 @@ async fn main() {
let source_id = source.id; let source_id = source.id;
let task = tokio::spawn(async move { let task = tokio::spawn(async move {
match cm.connect_from_source(&p, source_id).await { if let Err(e) = cm.connect_from_source(&p, source_id).await {
Ok(_) => { tracing::error!("Failed to connect to source {}: {}", source_name, e);
// Subscribe to points for this source
if let Err(e) = cm.subscribe_points_from_source(source_id, None, &p).await {
tracing::error!("Failed to subscribe to points for source {}: {}", source_name, e);
}
}
Err(e) => {
tracing::error!("Failed to connect to source {}: {}", source_name, e);
}
} }
}); });