refactor(runtime): hide local disk map global (#4046)

This commit is contained in:
Zhengchao An
2026-06-29 14:57:14 +08:00
committed by GitHub
parent 4111ce1547
commit ad6be6a167
5 changed files with 23 additions and 16 deletions
+3 -2
View File
@@ -34,7 +34,7 @@ use tokio::{
use tokio_util::sync::CancellationToken;
use tracing::{debug, error, info, warn};
use super::{DiskError, EcstoreError, GLOBAL_LOCAL_DISK_MAP, HealDiskExt as _};
use super::{DiskError, EcstoreError, HealDiskExt as _, local_disk_map_read};
const KEEP_HEAL_TASK_STATUS_DURATION: Duration = Duration::from_secs(10 * 60);
const LOG_COMPONENT_HEAL: &str = "heal";
@@ -2101,7 +2101,8 @@ impl HealManager {
// Build list of endpoints that need healing
let mut endpoints = Vec::new();
let mut seen_returning_sets = HashSet::new();
for (_, disk_opt) in GLOBAL_LOCAL_DISK_MAP.read().await.iter() {
let local_disk_map = local_disk_map_read().await;
for (_, disk_opt) in local_disk_map.iter() {
if let Some(disk) = disk_opt {
let endpoint = disk.endpoint();
let runtime_state = disk.runtime_state();
+2 -8
View File
@@ -49,14 +49,8 @@ pub(crate) type Endpoint = EcstoreEndpoint;
pub(crate) type StorageError = EcstoreStorageError;
pub(crate) type LocalDiskMap = std::collections::HashMap<String, Option<DiskStore>>;
pub(crate) struct GlobalLocalDiskMap;
pub(crate) static GLOBAL_LOCAL_DISK_MAP: GlobalLocalDiskMap = GlobalLocalDiskMap;
impl GlobalLocalDiskMap {
pub(crate) async fn read(&self) -> tokio::sync::RwLockReadGuard<'static, LocalDiskMap> {
ecstore_local_disk_map_read().await
}
pub(crate) async fn local_disk_map_read() -> tokio::sync::RwLockReadGuard<'static, LocalDiskMap> {
ecstore_local_disk_map_read().await
}
#[cfg(test)]