import Foundation
enum APIError: Error, LocalizedError {
case invalidURL
case invalidResponse
case statusCode(Int)
use tokio::sync::broadcast;
pub struct Shutdown {
is_shutdown: bool,
notify: broadcast::Receiver<()>,
}
const RETRYABLE_STATUS = new Set([408, 429, 500, 502, 503, 504]);
export function fullJitter(attempt, baseDelay = 300, maxDelay = 10_000) {
const ceiling = Math.min(maxDelay, baseDelay * 2 ** attempt);
return Math.random() * ceiling;
}