pub struct HealthChecker { /* private fields */ }Expand description
Health checker
Tracks the health of various server components, runs deep probes, maintains health history, and aggregates dependency health.
Implementations§
Source§impl HealthChecker
impl HealthChecker
Sourcepub fn with_history_capacity(capacity: usize) -> Self
pub fn with_history_capacity(capacity: usize) -> Self
Create a new health checker with the given history capacity
Sourcepub fn set_status(&self, status: HealthStatus)
pub fn set_status(&self, status: HealthStatus)
Set overall status
Sourcepub fn status(&self) -> HealthStatus
pub fn status(&self) -> HealthStatus
Get current overall status
Sourcepub fn set_storage_healthy(&self, healthy: bool)
pub fn set_storage_healthy(&self, healthy: bool)
Mark storage as healthy
Sourcepub fn set_network_healthy(&self, healthy: bool)
pub fn set_network_healthy(&self, healthy: bool)
Mark network as healthy
Sourcepub fn set_cluster_enabled(&self, enabled: bool)
pub fn set_cluster_enabled(&self, enabled: bool)
Mark cluster mode as enabled
Sourcepub fn set_cluster_healthy(&self, healthy: bool)
pub fn set_cluster_healthy(&self, healthy: bool)
Mark cluster as healthy
Sourcepub fn uptime_seconds(&self) -> u64
pub fn uptime_seconds(&self) -> u64
Get uptime in seconds
Sourcepub fn is_alive(&self) -> bool
pub fn is_alive(&self) -> bool
Check if server is alive (not shutting down or unhealthy). This is a lightweight check suitable for liveness probes.
Sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Check if server is ready to serve traffic. Returns false during startup, shutdown, and recovery.
Sourcepub fn liveness_response(&self) -> LivenessResponse
pub fn liveness_response(&self) -> LivenessResponse
Build a liveness response (lightweight, fast)
Sourcepub fn readiness_response(&self) -> ReadinessResponse
pub fn readiness_response(&self) -> ReadinessResponse
Build a readiness response (includes component and dependency info)
Sourcepub fn register_probe(
&self,
name: impl Into<String>,
probe: Arc<dyn DeepHealthCheck>,
)
pub fn register_probe( &self, name: impl Into<String>, probe: Arc<dyn DeepHealthCheck>, )
Register a deep health probe under the given name
Sourcepub async fn run_probes(&self) -> HashMap<String, HealthProbeResult>
pub async fn run_probes(&self) -> HashMap<String, HealthProbeResult>
Run all registered deep probes and return their results
Sourcepub fn register_dependency(
&self,
name: impl Into<String>,
checker: Arc<dyn DeepHealthCheck>,
)
pub fn register_dependency( &self, name: impl Into<String>, checker: Arc<dyn DeepHealthCheck>, )
Register a dependency health checker
Sourcepub async fn check_dependencies(&self) -> ProbeStatus
pub async fn check_dependencies(&self) -> ProbeStatus
Run all dependency checks and update cached results. Returns the aggregated worst status.
Sourcepub fn aggregated_dependency_status(&self) -> ProbeStatus
pub fn aggregated_dependency_status(&self) -> ProbeStatus
Get the current aggregated dependency status (from cached results)
Sourcepub fn record_snapshot(&self)
pub fn record_snapshot(&self)
Record a snapshot of the current health state into the history buffer
Sourcepub fn health_history(&self) -> Vec<HealthSnapshot>
pub fn health_history(&self) -> Vec<HealthSnapshot>
Get the health check history as a chronologically ordered list
Sourcepub fn uptime_percent(&self) -> f64
pub fn uptime_percent(&self) -> f64
Get the uptime percentage from the history buffer
Sourcepub fn get_health(&self) -> HealthCheckResponse
pub fn get_health(&self) -> HealthCheckResponse
Get full health check response (enhanced with probes, deps, history)
Sourcepub async fn get_health_deep(&self) -> HealthCheckResponse
pub async fn get_health_deep(&self) -> HealthCheckResponse
Get full health check response including deep probe results (async)
Sourcepub fn get_health_json(&self) -> Result<String, Error>
pub fn get_health_json(&self) -> Result<String, Error>
Format health as JSON
Trait Implementations§
Source§impl Clone for HealthChecker
impl Clone for HealthChecker
Source§fn clone(&self) -> HealthChecker
fn clone(&self) -> HealthChecker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for HealthChecker
impl !RefUnwindSafe for HealthChecker
impl Send for HealthChecker
impl Sync for HealthChecker
impl Unpin for HealthChecker
impl UnsafeUnpin for HealthChecker
impl !UnwindSafe for HealthChecker
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.