Skip to main content

RateLimitInterceptor

Upgather SDK


Upgather SDK / RateLimitInterceptor

Class: RateLimitInterceptor

RequestInterceptor implementation that enforces rate limits.

Remarks

This interceptor uses the token bucket algorithm to limit the rate of requests sent to backend services, preventing them from being overwhelmed.

Implements

Constructors

new RateLimitInterceptor()

new RateLimitInterceptor(options): RateLimitInterceptor

Creates a new rate limiting interceptor.

Parameters

options

RateLimitOptions

Rate limiting configuration options

Returns

RateLimitInterceptor

Methods

intercept()

intercept(request): HttpRequest

Intercept the request and apply rate limiting.

Parameters

request

HttpRequest

The HTTP request to intercept

Returns

HttpRequest

The request if allowed to proceed

Throws

Error if rate limited and not configured to wait

Fix: Change Promise to HttpRequest for signature compatibility

Implementation of

RequestInterceptor.intercept


interceptAsync()

interceptAsync(request): Promise<HttpRequest>

Asynchronous version for cases where the interceptor can be explicitly called rather than through the standard interceptor chain.

Parameters

request

HttpRequest

The HTTP request to intercept

Returns

Promise<HttpRequest>

Promise resolving to the request once rate limiting is satisfied