perf(ecstore): batch delete object lock acquisition (#2374)

Co-authored-by: 安正超 <anzhengchao@gmail.com>
This commit is contained in:
weisd
2026-04-03 21:46:51 +08:00
committed by GitHub
parent 2d91e2f580
commit 25512e2635
14 changed files with 1120 additions and 142 deletions
+17
View File
@@ -17,6 +17,7 @@ pub mod local;
use crate::{LockId, LockInfo, LockRequest, LockResponse, LockStats, Result};
use async_trait::async_trait;
use futures::future::join_all;
use std::sync::Arc;
/// Lock client trait
@@ -25,9 +26,25 @@ pub trait LockClient: Send + Sync + std::fmt::Debug {
/// Acquire lock (generic method)
async fn acquire_lock(&self, request: &LockRequest) -> Result<LockResponse>;
/// Acquire multiple locks. Default implementation fans out to single-lock requests.
async fn acquire_locks_batch(&self, requests: &[LockRequest]) -> Result<Vec<LockResponse>> {
Ok(join_all(requests.iter().map(|request| self.acquire_lock(request)))
.await
.into_iter()
.collect::<Result<Vec<_>>>()?)
}
/// Release lock
async fn release(&self, lock_id: &LockId) -> Result<bool>;
/// Release multiple locks. Default implementation fans out to single-lock releases.
async fn release_locks_batch(&self, lock_ids: &[LockId]) -> Result<Vec<bool>> {
Ok(join_all(lock_ids.iter().map(|lock_id| self.release(lock_id)))
.await
.into_iter()
.collect::<Result<Vec<_>>>()?)
}
/// Refresh lock
async fn refresh(&self, lock_id: &LockId) -> Result<bool>;