add concurrent thread config

This commit is contained in:
2026-04-11 11:39:35 +08:00
parent d9461d1ef0
commit 3d5ca3b1f8
5 changed files with 22 additions and 11 deletions
+2 -1
View File
@@ -16,5 +16,6 @@ pub struct Profile {
#[serde(flatten)]
pub sync_context: SyncContext,
pub path: String,
pub interval: Option<u64>
pub interval: Option<u64>,
pub concurrent: Option<usize>,
}
+15 -2
View File
@@ -29,6 +29,7 @@ pub async fn run(
.await?,
);
let manifest_snapshot = { local_manifest.manifest.read().await.clone() };
let all_cnt = sync_resp.tasks.len();
let tasks = sync_resp
.tasks
.into_iter()
@@ -40,8 +41,20 @@ pub async fn run(
}
})
.collect::<Vec<_>>();
info!("[{}]: Collected {} tasks", profile.0, tasks.len());
let n = 5;
info!(
"[{}]: Collected {}/{} tasks",
profile.0,
tasks.len(),
all_cnt
);
if tasks.is_empty() {
info!("[{}]: No tasks to sync, skipping", profile.0);
let req = CloseRequest { id: id.clone() };
close(&mut client.get_client().await?, &req).await?;
return Ok(true);
}
let n = profile.1.concurrent.unwrap_or(5);
info!("[{}]: Start sync with {} thread", profile.0, n);
let semaphore = Arc::new(Semaphore::new(n));
let mut join_set = JoinSet::new();
for task in tasks {