Maintains the request queue, processing flag, and last request timestamp.
Provides atomic accessors for state coordination between processor and other modules.
Source
exportinterfaceQueueEntry { /** Function to call when the request is ready to proceed. */ resolve: (value: void) =>void; /** Current attempt number (0-based). */ attempt?: number; /** Maximum number of attempts allowed. */ maxAttempts?: number; /** Timestamp (ms) when this entry is eligible to be processed (for backoff). */ nextEligibleAt?: number; /** Optional callback invoked if all retries are exhausted. */ onRetryFailed?: (error: Error) =>void; }
/** * Timestamp of the last API request in milliseconds. * @source */ letlastRequestTime = 0;
/** * Get the timestamp of the last request. * @returns Milliseconds since epoch of the last request, or 0 if never requested. * @source */ exportfunctiongetLastRequestTime(): number { returnlastRequestTime; }
/** * Set the timestamp of the last request. * @paramtime - Milliseconds since epoch. * @source */ exportfunctionsetLastRequestTime(time: number): void { lastRequestTime = time; }
/** * Flag indicating whether the queue processor is currently running. * @source */ letprocessingQueueActive = false;
/** * Check if the queue is currently being processed. * @returns True if the queue processor is active. * @source */ exportfunctionisProcessingQueue(): boolean { returnprocessingQueueActive; }
/** * Set the queue processing flag. * @paramvalue - Whether the processor is running. * @source */ exportfunctionsetProcessingQueue(value: boolean): void { processingQueueActive = value; }
Rate limit queue state management.
Maintains the request queue, processing flag, and last request timestamp. Provides atomic accessors for state coordination between processor and other modules.
Source