refactor(rpc): use node name accessor in health handlers (#1972)

This commit is contained in:
安正超
2026-02-26 19:37:16 +08:00
committed by GitHub
parent 40903ec2af
commit dafb31d208
3 changed files with 15 additions and 7 deletions
+8
View File
@@ -38,6 +38,14 @@ pub async fn set_global_local_node_name(name: &str) {
*GLOBAL_LOCAL_NODE_NAME.write().await = name.to_string();
}
/// Get the global local node name.
///
/// # Returns
/// * `String` - The local node name.
pub async fn get_global_local_node_name() -> String {
GLOBAL_LOCAL_NODE_NAME.read().await.clone()
}
/// Set the global RustFS initialization time to the current UTC time.
pub async fn set_global_init_time_now() {
let now = Utc::now();
+6 -6
View File
@@ -19,7 +19,7 @@ impl NodeService {
&self,
_request: Request<GetProcInfoRequest>,
) -> Result<Response<GetProcInfoResponse>, Status> {
let addr = GLOBAL_LOCAL_NODE_NAME.read().await.clone();
let addr = get_global_local_node_name().await;
let info = get_proc_info(&addr);
let mut buf = Vec::new();
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
@@ -40,7 +40,7 @@ impl NodeService {
&self,
_request: Request<GetMemInfoRequest>,
) -> Result<Response<GetMemInfoResponse>, Status> {
let addr = GLOBAL_LOCAL_NODE_NAME.read().await.clone();
let addr = get_global_local_node_name().await;
let info = get_mem_info(&addr);
let mut buf = Vec::new();
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
@@ -61,7 +61,7 @@ impl NodeService {
&self,
_request: Request<GetSysErrorsRequest>,
) -> Result<Response<GetSysErrorsResponse>, Status> {
let addr = GLOBAL_LOCAL_NODE_NAME.read().await.clone();
let addr = get_global_local_node_name().await;
let info = get_sys_errors(&addr);
let mut buf = Vec::new();
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
@@ -82,7 +82,7 @@ impl NodeService {
&self,
_request: Request<GetSysConfigRequest>,
) -> Result<Response<GetSysConfigResponse>, Status> {
let addr = GLOBAL_LOCAL_NODE_NAME.read().await.clone();
let addr = get_global_local_node_name().await;
let info = get_sys_config(&addr);
let mut buf = Vec::new();
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
@@ -103,7 +103,7 @@ impl NodeService {
&self,
_request: Request<GetSeLinuxInfoRequest>,
) -> Result<Response<GetSeLinuxInfoResponse>, Status> {
let addr = GLOBAL_LOCAL_NODE_NAME.read().await.clone();
let addr = get_global_local_node_name().await;
let info = get_sys_services(&addr);
let mut buf = Vec::new();
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
@@ -164,7 +164,7 @@ impl NodeService {
&self,
_request: Request<GetNetInfoRequest>,
) -> Result<Response<GetNetInfoResponse>, Status> {
let addr = GLOBAL_LOCAL_NODE_NAME.read().await.clone();
let addr = get_global_local_node_name().await;
let info = get_net_info(&addr, "");
let mut buf = Vec::new();
if let Err(err) = info.serialize(&mut Serializer::new(&mut buf)) {
+1 -1
View File
@@ -16,7 +16,7 @@ use bytes::Bytes;
use futures::Stream;
use futures_util::future::join_all;
use rmp_serde::{Deserializer, Serializer};
use rustfs_common::{GLOBAL_LOCAL_NODE_NAME, heal_channel::HealOpts};
use rustfs_common::{get_global_local_node_name, heal_channel::HealOpts};
use rustfs_ecstore::{
admin_server_info::get_local_server_property,
bucket::{metadata::load_bucket_metadata, metadata_sys},