pub struct StorageHealthMonitor { /* private fields */ }Expand description
Monitors the health of storage subsystems.
Maintains a set of named health checks, supports tick-based scheduling, and computes an overall status from the worst individual check.
Implementations§
Source§impl StorageHealthMonitor
impl StorageHealthMonitor
Sourcepub fn new(config: HealthMonitorConfig) -> Self
pub fn new(config: HealthMonitorConfig) -> Self
Create a new monitor with the given configuration.
Sourcepub fn register_check(&mut self, name: &str)
pub fn register_check(&mut self, name: &str)
Register a named health check with Unknown status.
Sourcepub fn update_check(
&mut self,
name: &str,
status: MonitorHealthStatus,
message: &str,
) -> Result<(), String>
pub fn update_check( &mut self, name: &str, status: MonitorHealthStatus, message: &str, ) -> Result<(), String>
Update the status and message of an existing check.
Returns Err if no check with the given name is registered.
Sourcepub fn evaluate_utilization(
&self,
current: u64,
capacity: u64,
) -> MonitorHealthStatus
pub fn evaluate_utilization( &self, current: u64, capacity: u64, ) -> MonitorHealthStatus
Evaluate a utilization ratio against the configured thresholds.
capacity of zero is treated as Unhealthy.
Sourcepub fn overall_health(&self) -> MonitorHealthStatus
pub fn overall_health(&self) -> MonitorHealthStatus
Compute the overall health as the worst status among all checks.
Returns Healthy when there are no registered checks.
Sourcepub fn get_check(&self, name: &str) -> Option<&MonitorHealthCheck>
pub fn get_check(&self, name: &str) -> Option<&MonitorHealthCheck>
Retrieve a reference to a named check, if it exists.
Sourcepub fn should_check(&self) -> bool
pub fn should_check(&self) -> bool
Returns true when enough ticks have elapsed since the last check run.
Sourcepub fn run_checks(&mut self)
pub fn run_checks(&mut self)
Execute a check cycle: update bookkeeping and recompute overall status.
Sourcepub fn healthy_count(&self) -> usize
pub fn healthy_count(&self) -> usize
Count of checks currently Healthy.
Sourcepub fn degraded_count(&self) -> usize
pub fn degraded_count(&self) -> usize
Count of checks currently Degraded.
Sourcepub fn unhealthy_count(&self) -> usize
pub fn unhealthy_count(&self) -> usize
Count of checks currently Unhealthy.
Sourcepub fn all_checks(&self) -> Vec<&MonitorHealthCheck>
pub fn all_checks(&self) -> Vec<&MonitorHealthCheck>
Return references to all registered checks.
Sourcepub fn stats(&self) -> HealthMonitorStats
pub fn stats(&self) -> HealthMonitorStats
Produce a statistics snapshot.
Auto Trait Implementations§
impl Freeze for StorageHealthMonitor
impl RefUnwindSafe for StorageHealthMonitor
impl Send for StorageHealthMonitor
impl Sync for StorageHealthMonitor
impl Unpin for StorageHealthMonitor
impl UnsafeUnpin for StorageHealthMonitor
impl UnwindSafe for StorageHealthMonitor
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more