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
+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()
}