@elasticapi/wpengine-typescript-sdk
Version:
Unofficial TypeScript SDK for the WP Engine API
35 lines • 945 B
TypeScript
/**
* Token bucket rate limiter implementation
*/
export declare class RateLimiter {
private tokens;
private lastRefill;
private readonly maxTokens;
private readonly refillRate;
private readonly refillInterval;
constructor(maxRequestsPerSecond?: number);
/**
* Refills tokens based on time elapsed
*/
private refillTokens;
/**
* Checks if a request can be made and consumes a token if available
* @returns Promise that resolves when a token is available
*/
acquireToken(): Promise<void>;
/**
* Gets the number of tokens currently available
*/
getAvailableTokens(): number;
/**
* Gets the time in milliseconds until the next token will be available
*/
getWaitTime(): number;
}
/**
* Rate limiter error class
*/
export declare class RateLimitError extends Error {
constructor(message: string);
}
//# sourceMappingURL=rate-limiter.d.ts.map