pub struct GatewayRingPolicy {
pub failure_threshold: u32,
pub cooldown: Option<Duration>,
}Expand description
What RuntimeBuilder::with_gateway_ring and its two companions take
and report, under the same rule as the provider-authoring types above: the
builder makes a host name these, so basis re-exports them. The ring itself
stays in mentra (ADR-0027); GatewayMember is basis’s own, because it
carries a URL the way RuntimeBuilder::with_base_url takes one.
How a ring decides when to leave a member and when to come back.
Fields§
§failure_threshold: u32Consecutive counted failures on the active member before the ring rotates away from it.
Counted across calls, not within one: a member that fails, is retried
by the runtime’s own backoff, and fails again has a streak of two.
For the rotation to happen inside a single turn this should be no
larger than the runtime’s retry budget; a larger threshold still
rotates, just across turns. 0 is read as 1.
cooldown: Option<Duration>How long a member the ring rotated away from rests before a more preferred one is tried again.
Some makes the ring drift back: once the preferred member has rested
this long, the next call probes it, and one failure sends the ring back
to where it was. None makes the ring sticky: it stays on whichever
member last worked, and only reaches an earlier one by rotating all the
way around.
Implementations§
Source§impl GatewayRingPolicy
impl GatewayRingPolicy
Sourcepub const DEFAULT_FAILURE_THRESHOLD: u32 = 5
pub const DEFAULT_FAILURE_THRESHOLD: u32 = 5
Five consecutive failures, then rotate; drift back to the preferred member after it has rested a minute.
Sourcepub const DEFAULT_COOLDOWN: Duration
pub const DEFAULT_COOLDOWN: Duration
Sourcepub const fn sticky() -> GatewayRingPolicy
pub const fn sticky() -> GatewayRingPolicy
A sticky ring: rotate on the default threshold and never drift back.
Sourcepub const fn with_failure_threshold(
self,
failure_threshold: u32,
) -> GatewayRingPolicy
pub const fn with_failure_threshold( self, failure_threshold: u32, ) -> GatewayRingPolicy
The same policy with a different failure threshold.
Sourcepub const fn with_cooldown(
self,
cooldown: Option<Duration>,
) -> GatewayRingPolicy
pub const fn with_cooldown( self, cooldown: Option<Duration>, ) -> GatewayRingPolicy
The same policy with a different cooldown, or none.
Trait Implementations§
Source§impl Clone for GatewayRingPolicy
impl Clone for GatewayRingPolicy
Source§fn clone(&self) -> GatewayRingPolicy
fn clone(&self) -> GatewayRingPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more