Expand description
Rotation state: which accounts are exhausted, when their cooldowns end, and how many 429s are on the streak.
Four triggers mark an account exhausted (spec, Rotation): a
rate_limit_event whose status is not allowed, a
anthropic-ratelimit-unified-status / -overage-status of
rejected on the failing response, any window at 100% utilization
with a reset ahead, and five consecutive 429s from one account
inside 60 seconds. The first three are proven exhaustion; the
streak is the heuristic, which is why its numbers are config.
Re-exports§
use std::collections::HashMap;🔒use std::time::Duration;🔒use std::time::SystemTime;🔒use parking_lot::Mutex;🔒use crate::account::AccountKey;🔒
Structs§
- Rotation
Numbers - The rotation numbers from
[gateway]: how many 429s fire the streak, the window they are counted over, and the cooldown when no reset time is known. - Rotation
State - Per-account rotation state: cooldown end, and the streak.
Constants§
- NO_
RESET_ COOLDOWN - The default cooldown applied when neither the failing response nor the account’s own usage probe reports a reset time.
- STREAK_
COUNT - The default streak: this many consecutive 429s from one account
inside
STREAK_WINDOWfire the rotation. - STREAK_
WINDOW - The default window the streak is counted over.
Functions§
- reset_
instant - A unix-seconds reset time, as the wire frames and headers carry.