UNPKG

@hisorange/resistor

Version:

Versatily resource load throttler with extensible strategies, configuration and virtual thread management.

18 lines (17 loc) 654 B
import { IStrategy } from '../interfaces/strategy.interface'; import { WaitPass } from '../interfaces/wait-pass.interface'; interface IRateLimterConfig { interval: number; occurrence: number; } /** * Restricts the executions count in the given interval to respect a rate limiter. */ export declare class RateLimiterStrategy implements IStrategy { protected threadActivity: Map<number, number[]>; protected config: IRateLimterConfig; constructor(config: Partial<IRateLimterConfig>); handleWaitPass(threadId: number, waitPass: WaitPass): Promise<void>; threadFinished(threadId: number, activityAt: number): void; } export {};