use std::time::Duration;
use crate::hedging::constants::{DEFAULT_HEDGING_DELAY, DEFAULT_MAX_HEDGED_ATTEMPTS};
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(any(feature = "serde", test), derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct HedgingConfig {
pub enabled: bool,
#[cfg_attr(
any(feature = "serde", test),
serde(with = "jiff::fmt::serde::unsigned_duration::friendly::compact::required")
)]
pub hedging_delay: Duration,
pub max_hedged_attempts: u8,
pub handle_unavailable: bool,
}
impl Default for HedgingConfig {
fn default() -> Self {
Self {
enabled: true,
hedging_delay: DEFAULT_HEDGING_DELAY,
max_hedged_attempts: DEFAULT_MAX_HEDGED_ATTEMPTS,
handle_unavailable: false,
}
}
}
#[cfg_attr(coverage_nightly, coverage(off))]
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[cfg_attr(miri, ignore)]
fn default_snapshot() {
let config = HedgingConfig::default();
insta::assert_json_snapshot!(config);
}
}