bridge/classes/RateLimiter.md
Rate limiter that ensures a minimum interval between requests. Tasks run one at a time, in the order they were scheduled; the interval is measured between task starts.
Constructors
Constructor
new RateLimiter(
requestsPerSecond):RateLimiter
Create a new rate limiter
Parameters
| Parameter | Type | Description |
|---|---|---|
requestsPerSecond | number | Maximum requests per second |
Returns
RateLimiter
Throws
GalaSDKError INVALID_BRIDGE_OPTION (requestsPerSecond) unless it is a number above
zero (NaN would silently disable the limit)
requests per second rate limiter invalid bridge option
Methods
schedule()
schedule<
T>(task):Promise<T>
Schedule a task to run within rate limits. Tasks run serially, inside the chain, so concurrent callers can never exceed the limit.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
task | () => Promise<T> | The async task to execute |
Returns
Promise<T>
The result of the task; its failure (whatever it threw) as the rejection