Appearance
Rule.io SDK / client/src / RateLimitOptions
Interface: RateLimitOptions
Defined in: client/src/core/rate-limit.ts:40
User-facing rate-limit configuration. All fields optional with defaults.
Example
typescript
const client = new RuleClient({
apiKey: process.env.RULE_API_KEY!,
rateLimiting: {
maxConcurrency: 4,
maxRetries: 2,
onRetry: ({ label, attempt, delayMs, honoredRetryAfter }) => {
console.warn(
`[rate-limit] retry ${attempt} of ${label} in ${delayMs} ms` +
(honoredRetryAfter ? ' (server Retry-After)' : ' (backoff)')
);
},
},
});Properties
baseDelayMs?
optionalbaseDelayMs?:number
Defined in: client/src/core/rate-limit.ts:46
Base delay in ms for exponential backoff when no Retry-After header. Default: 1000.
maxConcurrency?
optionalmaxConcurrency?:number
Defined in: client/src/core/rate-limit.ts:42
Maximum concurrent in-flight HTTP requests. Default: 4.
maxDelayMs?
optionalmaxDelayMs?:number
Defined in: client/src/core/rate-limit.ts:48
Cap in ms for the exponential-backoff fallback. Default: 8000.
maxRetries?
optionalmaxRetries?:number
Defined in: client/src/core/rate-limit.ts:44
Number of retries on 429 (so total attempts = retries + 1). Default: 2.
maxRetryAfterMs?
optionalmaxRetryAfterMs?:number
Defined in: client/src/core/rate-limit.ts:54
Cap in ms for honoring a server-supplied Retry-After. If the header asks for a wait longer than this, the gate gives up and rethrows the 429 rather than stalling the caller. Default: 60_000 (60 s).
onRetry?
optionalonRetry?: (info) =>void
Defined in: client/src/core/rate-limit.ts:56
Hook invoked on each retry attempt.
Parameters
info
Returns
void
random?
optionalrandom?: () =>number
Defined in: client/src/core/rate-limit.ts:60
RNG for jitter, in [0, 1). Overridable for tests.
Returns
number
sleep?
optionalsleep?: (ms) =>Promise<void>
Defined in: client/src/core/rate-limit.ts:58
Sleep function (overridable for tests).
Parameters
ms
number
Returns
Promise<void>