Skip to main content

Module rotation

Module rotation 

Source
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§

RotationNumbers
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.
RotationState
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_WINDOW fire 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.