/** * @fileoverview Global rate limiter for API requests. * @module meteo-lt-sdk/client/rate-limiter */ /** * Configuration for the rate limiter. */ export interface RateLimiterConfig { /** Maximum requests per window. Default: 180 */ readonly maxRequests: number; /** Time window in milliseconds. Default: 60000 (1 minute) */ readonly windowMs: number; } /** * A sliding window rate limiter that queues requests when limits are reached. * Uses a global singleton pattern to track requests across all MeteoClient instances. */ declare class RateLimiter { private readonly timestamps; private readonly config; private readonly queue; private processing; constructor(config?: Partial); /** * Acquires a slot to make a request. * If the rate limit is reached, the request is queued and will be * executed when a slot becomes available. */ acquire(): Promise; /** * Records a request without waiting for a slot. * Used when throttling is disabled but we still want accurate tracking. * This allows the rate limiter to have accurate counts even for non-throttled clients. */ record(): void; /** * Processes queued requests when slots become available. */ private processQueue; private sleep; /** * Gets time until next available slot in milliseconds. * Returns 0 if a slot is immediately available. */ getTimeUntilAvailable(): number; /** * Gets current usage info. */ getUsage(): { current: number; max: number; windowMs: number; }; } /** * Gets the global rate limiter instance, creating it if necessary. */ export declare function getGlobalRateLimiter(): RateLimiter; /** * Resets the global rate limiter. Mainly useful for testing. */ export declare function resetGlobalRateLimiter(): void; export { RateLimiter }; //# sourceMappingURL=rate-limiter.d.ts.map