refactor(config): move global config accessors (#3360)

This commit is contained in:
安正超
2026-06-11 19:16:02 +08:00
committed by GitHub
parent ed3851782c
commit b4524033e3
15 changed files with 131 additions and 65 deletions
+5 -13
View File
@@ -34,14 +34,16 @@ use rustfs_config::notify::{
NOTIFY_POSTGRES_SUB_SYS, NOTIFY_PULSAR_SUB_SYS, NOTIFY_REDIS_SUB_SYS, NOTIFY_WEBHOOK_SUB_SYS,
};
use rustfs_config::oidc::IDENTITY_OPENID_SUB_SYS;
use rustfs_config::server_config::{Config, register_default_kvs};
use rustfs_config::server_config::register_default_kvs;
use std::collections::HashMap;
use std::sync::LazyLock;
use std::sync::{Arc, RwLock};
// RUSTFS_COMPAT_TODO(CFG-008): keep old ecstore global server-config accessor path while runtime consumers migrate. Remove after all consumers import these accessors from rustfs_config::server_config.
pub use rustfs_config::server_config::{get_global_server_config, set_global_server_config};
pub static GLOBAL_STORAGE_CLASS: LazyLock<RwLock<storageclass::Config>> =
LazyLock::new(|| RwLock::new(storageclass::Config::default()));
pub static GLOBAL_SERVER_CONFIG: LazyLock<RwLock<Option<Config>>> = LazyLock::new(|| RwLock::new(None));
pub static GLOBAL_CONFIG_SYS: LazyLock<ConfigSys> = LazyLock::new(ConfigSys::new);
pub static RUSTFS_CONFIG_PREFIX: &str = "config";
@@ -69,16 +71,6 @@ impl ConfigSys {
}
}
pub fn get_global_server_config() -> Option<Config> {
GLOBAL_SERVER_CONFIG.read().ok().and_then(|guard| (*guard).clone())
}
pub fn set_global_server_config(cfg: Config) {
if let Ok(mut guard) = GLOBAL_SERVER_CONFIG.write() {
*guard = Some(cfg);
}
}
pub fn get_global_storage_class() -> Option<storageclass::Config> {
GLOBAL_STORAGE_CLASS.read().ok().map(|guard| (*guard).clone())
}
@@ -132,7 +124,7 @@ pub fn init() {
#[cfg(test)]
mod tests {
use super::*;
use rustfs_config::server_config::KVS;
use rustfs_config::server_config::{Config, KVS};
use rustfs_config::{
DEFAULT_DELIMITER, DEFAULT_HEAL_BITROT_CYCLE_SECS, DEFAULT_SCANNER_SPEED, HEAL_BITROT_CYCLE, SCANNER_CYCLE_MAX_OBJECTS,
SCANNER_DELAY, SCANNER_MAX_WAIT, SCANNER_SPEED, SCANNER_SUB_SYS,