pub struct HealthPolicy {
pub heartbeat_timeout: Duration,
pub max_replication_lag: u64,
pub max_recent_errors: u32,
pub failover_threshold: u8,
pub degraded_threshold: u8,
pub grace_period: Duration,
}Expand description
The tunables that turn raw signals into a HealthScore and gate failover.
The defaults (HealthPolicy::default) are deliberately conservative:
generous enough that an ordinary hiccup does not trip a failover, with a
grace period long enough to ride out a transient blip.
Fields§
§heartbeat_timeout: DurationHeartbeat age at or beyond which the liveness sub-score bottoms out at 0.
max_replication_lag: u64Replication lag (LSNs) at or beyond which the lag sub-score bottoms out.
max_recent_errors: u32Recent-error count at or beyond which the error sub-score bottoms out.
failover_threshold: u8Score (inclusive) at or below which a member is Failed.
degraded_threshold: u8Score (inclusive) at or below which a member is at least
Degraded. Must be >= failover_threshold.
grace_period: DurationHow long a member must stay continuously Failed before the supervisor
will fail it over. The flapping damper: a shorter blip never triggers a
transition.
Implementations§
Source§impl HealthPolicy
impl HealthPolicy
Sourcepub fn evaluate(&self, signals: &MemberSignals) -> HealthScore
pub fn evaluate(&self, signals: &MemberSignals) -> HealthScore
Combine raw signals into a HealthScore under this policy.
The three serving signals fold into the overall score with a
liveness-heavy weighting (liveness 70%, lag 20%, errors 10%): a member
whose heartbeat has fully lapsed must be able to reach the failover
threshold on liveness alone — a crashed node stops heartbeating but its
last-known lag and error counts may still look fine, so trusting them
would wedge failover shut. At the same time a live owner that is far
behind or erroring is penalised rather than trusted blindly, and a
brief heartbeat gap with good lag/errors stays out of the failover band
(which a single short fixed timeout could not express). The grace-period
signal (unhealthy_for) is not part of the score — it gates the
failover action in failover_eligible.
Sourcepub fn failover_eligible(
&self,
score: &HealthScore,
signals: &MemberSignals,
) -> bool
pub fn failover_eligible( &self, score: &HealthScore, signals: &MemberSignals, ) -> bool
Whether a member with this score and these signals is eligible for
automatic failover: it must be Failed and
have stayed unhealthy for at least the grace period. A Failed member
still inside the grace window is held back — the flapping damper.
Trait Implementations§
Source§impl Clone for HealthPolicy
impl Clone for HealthPolicy
Source§fn clone(&self) -> HealthPolicy
fn clone(&self) -> HealthPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for HealthPolicy
Source§impl Debug for HealthPolicy
impl Debug for HealthPolicy
Source§impl Default for HealthPolicy
impl Default for HealthPolicy
Source§fn default() -> HealthPolicy
fn default() -> HealthPolicy
impl Eq for HealthPolicy
Source§impl PartialEq for HealthPolicy
impl PartialEq for HealthPolicy
Source§fn eq(&self, other: &HealthPolicy) -> bool
fn eq(&self, other: &HealthPolicy) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for HealthPolicy
Auto Trait Implementations§
impl Freeze for HealthPolicy
impl RefUnwindSafe for HealthPolicy
impl Send for HealthPolicy
impl Sync for HealthPolicy
impl Unpin for HealthPolicy
impl UnsafeUnpin for HealthPolicy
impl UnwindSafe for HealthPolicy
Blanket Implementations§
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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::Request