pub async fn rate_limit_archlinux() -> OwnedSemaphorePermitExpand description
What: Apply rate limiting specifically for archlinux.org requests with exponential backoff.
Inputs: None
Output: OwnedSemaphorePermit that the caller MUST hold during the request.
ยงPanics
- Panics if the archlinux.org request semaphore is closed (should never happen in practice).
Details:
- Acquires a semaphore permit to serialize archlinux.org requests (only 1 at a time).
- Uses base delay (500ms) for archlinux.org to reduce request frequency.
- Implements exponential backoff: increases delay on consecutive failures (500ms โ 1s โ 2s โ 4s, max 60s).
- Adds random jitter (0-500ms) to prevent thundering herd when multiple clients retry simultaneously.
- Resets backoff after successful requests.
- Thread-safe via mutex guarding the rate limiter state.
- The returned permit MUST be held until the HTTP request completes to ensure serialization.