本页还没有译文
本页 76 段还没译成Français,下面显示的是英文原文。AsyncRateLimiterOptions
还没翻译译自英文(tanstack.com)本页 76 段都还没译
Defined in: async-rate-limiter.ts:71
Options for configuring an async rate-limited function
Type Parameters
TFn
TFn extends AnyAsyncFunction
Properties
asyncRetryerOptions?
optional asyncRetryerOptions?: AsyncRetryerOptions<TFn>;Defined in: async-rate-limiter.ts:75
Options for configuring the underlying async retryer
enabled?
optional enabled?: boolean | ((rateLimiter) => boolean);Defined in: async-rate-limiter.ts:81
Whether the rate limiter is enabled. When disabled, maybeExecute will not trigger any executions. Can be a boolean or a function that returns a boolean. Defaults to true.
initialState?
optional initialState?: Partial<AsyncRateLimiterState<TFn>>;Defined in: async-rate-limiter.ts:85
Initial state for the rate limiter
key?
optional key?: string;Defined in: async-rate-limiter.ts:90
Optional key to identify this async rate limiter instance. If provided, the async rate limiter will be identified by this key in the devtools and PacerProvider if applicable.
limit
limit: number | ((rateLimiter) => number);Defined in: async-rate-limiter.ts:95
Maximum number of executions allowed within the time window. Can be a number or a function that returns a number.
onError?
optional onError?: (error, args, rateLimiter) => void;Defined in: async-rate-limiter.ts:101
Optional error handler for when the rate-limited function throws. If provided, the handler will be called with the error and rate limiter instance. This can be used alongside throwOnError - the handler will be called before any error is thrown.
Parameters
error
Error
args
Parameters<TFn>
rateLimiter
AsyncRateLimiter<TFn>
Returns
void
onReject?
optional onReject?: (args, rateLimiter) => void;Defined in: async-rate-limiter.ts:109
Optional callback function that is called when an execution is rejected due to rate limiting
Parameters
args
Parameters<TFn>
rateLimiter
AsyncRateLimiter<TFn>
Returns
void
onSettled?
optional onSettled?: (args, rateLimiter) => void;Defined in: async-rate-limiter.ts:113
Optional function to call when the rate-limited function is executed
Parameters
args
Parameters<TFn>
rateLimiter
AsyncRateLimiter<TFn>
Returns
void
onSuccess?
optional onSuccess?: (result, args, rateLimiter) => void;Defined in: async-rate-limiter.ts:120
Optional function to call when the rate-limited function is executed
Parameters
result
Awaited<ReturnType<TFn>>
args
Parameters<TFn>
rateLimiter
AsyncRateLimiter<TFn>
Returns
void
throwOnError?
optional throwOnError?: boolean;Defined in: async-rate-limiter.ts:130
Whether to throw errors when they occur. Defaults to true if no onError handler is provided, false if an onError handler is provided. Can be explicitly set to override these defaults.
window
window: number | ((rateLimiter) => number);Defined in: async-rate-limiter.ts:135
Time window in milliseconds within which the limit applies. Can be a number or a function that returns a number.
windowType?
optional windowType?: "fixed" | "sliding";Defined in: async-rate-limiter.ts:142
Type of window to use for rate limiting
- 'fixed': Uses a fixed window that resets after the window period
- 'sliding': Uses a sliding window that allows executions as old ones expire Defaults to 'fixed'