fix: restore provider key circuit breaker backoff

This commit is contained in:
fawney19
2026-05-19 13:57:36 +08:00
parent 6a1da6a5ff
commit 7e9ca88e00
14 changed files with 525 additions and 42 deletions

View File

@@ -4,7 +4,7 @@ use aether_data_contracts::repository::candidates::{
use aether_data_contracts::repository::provider_catalog::StoredProviderCatalogKey;
const FAILURE_COOLDOWN_WINDOW_SECS: u64 = 60;
const FAILURE_COOLDOWN_THRESHOLD: usize = 2;
const FAILURE_COOLDOWN_THRESHOLD: usize = 8;
const ACTIVE_REQUEST_WINDOW_SECS: u64 = 300;
pub const PROVIDER_KEY_RPM_WINDOW_SECS: u64 = 60;
const PROBE_PHASE_REQUESTS: u32 = 100;
@@ -694,11 +694,16 @@ mod tests {
}
#[test]
fn cooldown_triggers_after_two_recent_failures() {
let recent_candidates = vec![
stored_candidate("one", RequestCandidateStatus::Failed, 95),
stored_candidate("two", RequestCandidateStatus::Cancelled, 99),
];
fn cooldown_triggers_after_eight_recent_failures() {
let recent_candidates = (0..8)
.map(|index| {
stored_candidate(
&format!("failed-{index}"),
RequestCandidateStatus::Failed,
92 + index,
)
})
.collect::<Vec<_>>();
assert!(is_candidate_in_recent_failure_cooldown(
&recent_candidates,