refactor(runtime): wrap boot time global (#4044)

This commit is contained in:
Zhengchao An
2026-06-29 14:21:31 +08:00
committed by GitHub
parent 809e77d5db
commit e012d1e799
5 changed files with 28 additions and 8 deletions
+2 -2
View File
@@ -112,7 +112,7 @@ pub mod event {
pub mod global {
pub use crate::runtime::global::{
GLOBAL_BOOT_TIME, GLOBAL_LOCAL_DISK_MAP, GLOBAL_TierConfigMgr, get_global_bucket_monitor, get_global_deployment_id,
GLOBAL_LOCAL_DISK_MAP, GLOBAL_TierConfigMgr, get_global_bucket_monitor, get_global_deployment_id,
get_global_endpoints_opt, get_global_lock_client, get_global_lock_clients, get_global_region, get_global_tier_config_mgr,
global_rustfs_port, is_dist_erasure, is_erasure, is_erasure_sd, is_first_cluster_node_local, new_object_layer_fn,
resolve_object_store_handle, set_global_endpoints, set_global_region, set_global_rustfs_port, set_object_store_resolver,
@@ -122,7 +122,7 @@ pub mod global {
pub mod runtime {
pub use crate::runtime::sources::{
bucket_monitor, expiry_state_handle, first_cluster_node_is_local, global_tier_config_mgr, local_disk_map_read,
boot_time, bucket_monitor, expiry_state_handle, first_cluster_node_is_local, global_tier_config_mgr, local_disk_map_read,
object_store_handle, setup_is_erasure, setup_is_erasure_sd, transition_state_handle,
};
}
+6 -3
View File
@@ -186,10 +186,13 @@ pub(crate) async fn rustfs_addr() -> String {
rustfs_common::get_global_addr().await
}
pub fn boot_time() -> Option<SystemTime> {
GLOBAL_BOOT_TIME.get().cloned()
}
pub(crate) fn boot_uptime_secs() -> u64 {
GLOBAL_BOOT_TIME
.get()
.and_then(|boot_time| SystemTime::now().duration_since(*boot_time).ok())
boot_time()
.and_then(|boot_time| SystemTime::now().duration_since(boot_time).ok())
.unwrap_or_default()
.as_secs()
}