Reference / @open-music-sdk/core / createRateLimiter
Function: createRateLimiter()
function createRateLimiter(options): tRateLimiter;Defined in: packages/core/src/rate-limit.ts:29
Token bucket: capacity requests may go at once, then one every 1/refillPerSecond seconds. Apple counts its limit per developer token, so share one limiter across every client using that token.
Parameters
options
How fast requests may go: how many at once, and how many a second after that.
capacity
number
How many requests may go at once, from a full bucket: a finite number of at least 1.
refillPerSecond
number
How many requests a second may go once the bucket is empty: a finite number above 0.
Returns
A limiter that grants in the order asked, one request per token in the bucket.
Throws
TypeError if options is no object, capacity is not a finite number of at least 1, or refillPerSecond is not a finite number above 0.