RateLimitOptions
Upgather Analytics / RateLimitOptions
Interface: RateLimitOptions
Configuration options for rate limiting behavior in the analytics client.
Remarks
Rate limiting helps prevent excessive API calls that could lead to throttling or degraded performance. These settings control how the client manages request rates.
When enabled, the client will enforce limits on how many requests are sent within a given time period, with configurable behavior for handling excess requests.
Example
import { RateLimitOptions } from '@upgather/analytics';
const options: RateLimitOptions = {
enabled: true,
requestsPerSecond: 5,
burstCapacity: 10,
waitWhenLimited: true,
maxWaitTime: 3000
};
Properties
burstCapacity?
optionalburstCapacity:number
Maximum burst capacity for requests.
Remarks
Allows temporary spikes above the requestsPerSecond rate, up to this capacity before throttling begins.
Default
10
enabled
enabled:
boolean
Whether rate limiting is enabled.
Remarks
When set to true, the client will enforce rate limits according to the other settings. When false, requests will be sent without rate limiting regardless of other settings.
Default
false
maxWaitTime?
optionalmaxWaitTime:number
Maximum time to wait in milliseconds when rate limited.
Remarks
Only applies when waitWhenLimited is true. If a request would need to wait longer than this time, an error is thrown instead.
Default
5000 (5 seconds)
requestsPerSecond
requestsPerSecond:
number
Maximum number of requests allowed per second.
Remarks
Defines the steady-state rate at which requests can be made. This value should be set according to API documentation or service limits.
Default
5
waitWhenLimited?
optionalwaitWhenLimited:boolean
Whether to wait when rate limited instead of throwing an error.
Remarks
When true, exceeding the rate limit will cause the client to wait until the request can be sent. When false, the client will throw an error.
Default
true