优化连接流程:connect_from_source自动处理订阅,简化main.rs
This commit is contained in:
parent
a2217a991c
commit
494cf1d656
|
|
@ -395,7 +395,13 @@ impl ConnectionManager {
|
|||
source.username.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(
|
||||
|
|
|
|||
10
src/main.rs
10
src/main.rs
|
|
@ -62,17 +62,9 @@ async fn main() {
|
|||
let source_id = source.id;
|
||||
|
||||
let task = tokio::spawn(async move {
|
||||
match cm.connect_from_source(&p, source_id).await {
|
||||
Ok(_) => {
|
||||
// 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) => {
|
||||
if let Err(e) = cm.connect_from_source(&p, source_id).await {
|
||||
tracing::error!("Failed to connect to source {}: {}", source_name, e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
tasks.push(task);
|
||||
|
|
|
|||
Loading…
Reference in New Issue