mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-27 16:48:58 +00:00
refactor(ecstore): migrate config globals into ECStore struct fields (#3219)
* refactor(ecstore): migrate config globals into ECStore struct fields Phase 2 of global singleton consolidation. Add server_config and storage_class fields to ECStore, sharing the same underlying data as the process-global LazyLock statics. New ECStore fields: - server_config: RwLock<Option<Config>> - storage_class: RwLock<storageclass::Config> New async accessor methods: - get_server_config() / set_server_config() - get_storage_class() / set_storage_class() Fields initialized with defaults in ECStore::new(), synced from globals after init() completes. Global functions preserved for backward compatibility. 1160 tests pass, clippy clean, full workspace compiles. * fix: address PR #3219 review comments - delegate to globals Accessors now delegate to process-global statics to avoid state drift: - get_server_config() delegates to get_global_server_config() - set_server_config() updates both global and local field - get_storage_class() delegates to get_global_storage_class() - set_storage_class() updates both global and local field - Removed stale sync code from init() - Changed fields to std::sync::RwLock for sync access 1160 tests pass. * fix: correct import order for cargo fmt * fix: simplify config accessors - delegate to globals without local state Remove local server_config and storage_class fields from ECStore. Accessors now purely delegate to process-global statics, eliminating the state drift risk identified in review. 1160 tests pass, formatting clean.
This commit is contained in:
@@ -206,6 +206,31 @@ impl std::fmt::Debug for ECStore {
|
||||
}
|
||||
}
|
||||
|
||||
/// Phase 2: Accessor methods for config globals
|
||||
/// These delegate to the process-global statics. No local state — the globals
|
||||
/// remain the single source of truth until the migration is complete.
|
||||
impl ECStore {
|
||||
/// Get server configuration (delegates to global)
|
||||
pub fn get_server_config(&self) -> Option<crate::config::Config> {
|
||||
crate::config::get_global_server_config()
|
||||
}
|
||||
|
||||
/// Set server configuration (delegates to global)
|
||||
pub fn set_server_config(&self, cfg: crate::config::Config) {
|
||||
crate::config::set_global_server_config(cfg);
|
||||
}
|
||||
|
||||
/// Get storage class configuration (delegates to global)
|
||||
pub fn get_storage_class(&self) -> Option<crate::config::storageclass::Config> {
|
||||
crate::config::get_global_storage_class()
|
||||
}
|
||||
|
||||
/// Set storage class configuration (delegates to global)
|
||||
pub fn set_storage_class(&self, cfg: crate::config::storageclass::Config) {
|
||||
crate::config::set_global_storage_class(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
// impl Clone for ECStore {
|
||||
// fn clone(&self) -> Self {
|
||||
// let pool_meta = match self.pool_meta.read() {
|
||||
|
||||
Reference in New Issue
Block a user