-
Notifications
You must be signed in to change notification settings - Fork 35
/
types.ts
55 lines (49 loc) · 1.42 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Octokit } from "@octokit/core";
import type { EndpointDefaults } from "@octokit/types";
import Bottleneck from "bottleneck";
type LimitHandler = (
retryAfter: number,
options: Required<EndpointDefaults>,
octokit: Octokit,
retryCount: number,
) => void;
export type SecondaryLimitHandler = {
onSecondaryRateLimit: LimitHandler;
};
export type ThrottlingOptionsBase = {
enabled?: boolean;
Bottleneck?: typeof Bottleneck;
id?: string;
timeout?: number;
connection?: Bottleneck.RedisConnection | Bottleneck.IORedisConnection;
/**
* @deprecated use `fallbackSecondaryRateRetryAfter`
*/
minimalSecondaryRateRetryAfter?: number;
fallbackSecondaryRateRetryAfter?: number;
retryAfterBaseValue?: number;
write?: Bottleneck.Group;
search?: Bottleneck.Group;
notifications?: Bottleneck.Group;
onRateLimit: LimitHandler;
};
export type ThrottlingOptions =
| (ThrottlingOptionsBase & SecondaryLimitHandler)
| (Partial<ThrottlingOptionsBase & SecondaryLimitHandler> & {
enabled: false;
});
export type Groups = {
global?: Bottleneck.Group;
write?: Bottleneck.Group;
search?: Bottleneck.Group;
notifications?: Bottleneck.Group;
};
export type State = {
clustering: boolean;
triggersNotification: (pathname: string) => boolean;
fallbackSecondaryRateRetryAfter: number;
retryAfterBaseValue: number;
retryLimiter: Bottleneck;
id: string;
} & Required<Groups> &
ThrottlingOptions;