Classservicesv0.8.2
RateLimiter
Tracks per-key usage windows and reports when a key is limited and when it frees up.
Each key holds a sliding window of hit expiry times, and is limited once its live-hit count reaches the window's limitlimit. Expired hits are dropped on the next read, and a background sweep drops fully-expired keys so the map does not grow without bound.
class RateLimiterclass RateLimiterMember visibility
Filter class members by access level.
public hit(
key: string,
window: RateLimitWindow
): RateLimitResultpublic hit(
key: string,
window: RateLimitWindow
): RateLimitResultParameter:
keyThe bucket to record against. The caller builds it from its own scope.
Parameter:
windowThe usage window to apply for this hit.
public peek(
key: string,
window: RateLimitWindow
): RateLimitResultpublic peek(
key: string,
window: RateLimitWindow
): RateLimitResult