pub struct FallbackConfig {
pub enabled: bool,
pub on_status: Vec<u16>,
pub on_rate_limit: bool,
pub with_replacement: bool,
pub max_attempts: Option<usize>,
pub backoff: Option<BackoffConfig>,
pub max_total_backoff_ms: Option<u64>,
}Expand description
Configuration for fallback behavior when requests fail
Fields§
§enabled: boolWhether fallback is enabled
on_status: Vec<u16>Status codes that trigger fallback to the next provider. Supports wildcards: 50 matches all 50x codes (500-509), 5 matches all 5xx codes (500-599). Common values: [429, 502, 503, 504] or [5] for all 5xx errors.
on_rate_limit: boolWhether to fallback on local rate limits (pool-level and provider-level). If true, hitting a local rate limit will try the next provider instead of returning 429.
with_replacement: boolWhen true, weighted random failover samples with replacement, allowing the same provider to be retried. Only affects WeightedRandom strategy.
max_attempts: Option<usize>Maximum number of failover attempts. Defaults to provider count.
This is an attempt budget above the LB strategy: values larger than the
provider count retry across additional passes through the pool (the
cascade restarts), so it is useful for every strategy — including a
single-provider Priority pool — not only with with_replacement: true.
backoff: Option<BackoffConfig>Inter-attempt backoff. When unset (default), attempts proceed with no delay.
max_total_backoff_ms: Option<u64>Cap on cumulative time spent sleeping between attempts, in milliseconds. When the next scheduled backoff would push the total past this cap, the retry loop terminates and the last error is returned to the client. Bounds only the inter-attempt sleeps, not upstream request time.
Implementations§
Source§impl FallbackConfig
impl FallbackConfig
Sourcepub fn should_fallback_on_status(&self, status: u16) -> bool
pub fn should_fallback_on_status(&self, status: u16) -> bool
Check if a status code should trigger fallback
Trait Implementations§
Source§impl Clone for FallbackConfig
impl Clone for FallbackConfig
Source§fn clone(&self) -> FallbackConfig
fn clone(&self) -> FallbackConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more