UNPKG

1.3 kBTypeScriptView Raw
1import type { DataCategory, TransportMakeRequestResponse } from '@sentry/types';
2export type RateLimits = Record<string, number>;
3export declare const DEFAULT_RETRY_AFTER: number;
4/**
5 * Extracts Retry-After value from the request header or returns default value
6 * @param header string representation of 'Retry-After' header
7 * @param now current unix timestamp
8 *
9 */
10export declare function parseRetryAfterHeader(header: string, now?: number): number;
11/**
12 * Gets the time that the given category is disabled until for rate limiting.
13 * In case no category-specific limit is set but a general rate limit across all categories is active,
14 * that time is returned.
15 *
16 * @return the time in ms that the category is disabled until or 0 if there's no active rate limit.
17 */
18export declare function disabledUntil(limits: RateLimits, dataCategory: DataCategory): number;
19/**
20 * Checks if a category is rate limited
21 */
22export declare function isRateLimited(limits: RateLimits, dataCategory: DataCategory, now?: number): boolean;
23/**
24 * Update ratelimits from incoming headers.
25 *
26 * @return the updated RateLimits object.
27 */
28export declare function updateRateLimits(limits: RateLimits, { statusCode, headers }: TransportMakeRequestResponse, now?: number): RateLimits;
29//# sourceMappingURL=ratelimit.d.ts.map
\No newline at end of file