Class: RateLimiter
GalaChain core SDK 1.0.0-rc.8 / bridge / RateLimiter
Class: RateLimiter
Defined in: packages/gala-core-sdk/dist/bridge.d.ts:2595
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
Defined in: packages/gala-core-sdk/dist/bridge.d.ts:2606
Create a new rate limiter
Parameters
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)
Methods
schedule()
schedule<
T>(task):Promise<T>
Defined in: packages/gala-core-sdk/dist/bridge.d.ts:2614
Schedule a task to run within rate limits. Tasks run serially, inside the chain, so concurrent callers can never exceed the limit.
Type Parameters
T
T
Parameters
task
() => Promise<T>
The async task to execute
Returns
Promise<T>
The result of the task; its failure (whatever it threw) as the rejection