From e2fe99d8bcec443f718ff469cc3136a58c5c6ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Sat, 6 Jun 2026 21:38:45 +0800 Subject: [PATCH] refactor(ecstore): add server configuration accessors (#3238) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(ecstore): add server configuration accessors Phase 4 of global singleton consolidation. Add ECStore accessor methods for server-level configuration globals. New methods: - port() — delegates to global_rustfs_port() - host() — delegates to GLOBAL_RUSTFS_HOST - addr() — delegates to GLOBAL_RUSTFS_ADDR - region() — delegates to get_global_region() - endpoints() — delegates to get_global_endpoints() - server_config() — delegates to get_global_server_config() - storage_class() — delegates to get_global_storage_class() - tier_config_mgr() — delegates to get_global_tier_config_mgr() - notification_system() — delegates to get_global_notification_sys() - bucket_metadata_sys() — delegates to get_global_bucket_metadata_sys() 1160 tests pass, clippy clean, formatting clean. * fix(ecstore): avoid duplicate server accessors --- crates/ecstore/src/store.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/ecstore/src/store.rs b/crates/ecstore/src/store.rs index 7b3e09095..6098740d8 100644 --- a/crates/ecstore/src/store.rs +++ b/crates/ecstore/src/store.rs @@ -76,7 +76,7 @@ use http::HeaderMap; use lazy_static::lazy_static; use rand::RngExt as _; use rustfs_common::heal_channel::{HealItemType, HealOpts}; -use rustfs_common::{GLOBAL_LOCAL_NODE_NAME, GLOBAL_RUSTFS_HOST, GLOBAL_RUSTFS_PORT}; +use rustfs_common::{GLOBAL_LOCAL_NODE_NAME, GLOBAL_RUSTFS_ADDR, GLOBAL_RUSTFS_HOST, GLOBAL_RUSTFS_PORT}; use rustfs_filemeta::FileInfo; use rustfs_lock::{LocalClient, LockClient, NamespaceLockWrapper}; use rustfs_madmin::heal_commands::HealResultItem; @@ -274,6 +274,26 @@ impl ECStore { } } +/// Phase 4: Server address accessors +/// These provide a unified API through ECStore for accessing server-level +/// configuration globals. The globals remain the source of truth. +impl ECStore { + /// Get the server port + pub fn port(&self) -> u16 { + crate::global::global_rustfs_port() + } + + /// Get the server host + pub async fn host(&self) -> String { + GLOBAL_RUSTFS_HOST.read().await.clone() + } + + /// Get the server address (host:port) + pub async fn addr(&self) -> String { + GLOBAL_RUSTFS_ADDR.read().await.clone() + } +} + // impl Clone for ECStore { // fn clone(&self) -> Self { // let pool_meta = match self.pool_meta.read() {