1 |
|
2 | import { ConnectionOptions } from 'tls';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export interface IORedisOptions {
|
9 | Connector?: any;
|
10 | retryStrategy?: (times: number) => number | void | null;
|
11 | |
12 |
|
13 |
|
14 |
|
15 | commandTimeout?: number;
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 | keepAlive?: number;
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 | noDelay?: boolean;
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 | connectionName?: string;
|
34 | |
35 |
|
36 |
|
37 |
|
38 | username?: string;
|
39 | |
40 |
|
41 |
|
42 | password?: string;
|
43 | |
44 |
|
45 |
|
46 |
|
47 |
|
48 | db?: number;
|
49 | |
50 |
|
51 |
|
52 |
|
53 |
|
54 | autoResubscribe?: boolean;
|
55 | |
56 |
|
57 |
|
58 |
|
59 |
|
60 | autoResendUnfulfilledCommands?: boolean;
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | reconnectOnError?: ((err: Error) => boolean | 1 | 2) | null;
|
83 | /**
|
84 | * @default false
|
85 | */
|
86 | readOnly?: boolean;
|
87 | /**
|
88 | * When enabled, numbers returned by Redis will be converted to JavaScript strings instead of numbers.
|
89 | * This is necessary if you want to handle big numbers (above `Number.MAX_SAFE_INTEGER` === 2^53).
|
90 | * @default false
|
91 | */
|
92 | stringNumbers?: boolean;
|
93 | /**
|
94 | * How long the client will wait before killing a socket due to inactivity during initial connection.
|
95 | * @default 10000
|
96 | */
|
97 | connectTimeout?: number;
|
98 | /**
|
99 | * This option is used internally when you call `redis.monitor()` to tell Redis
|
100 | * to enter the monitor mode when the connection is established.
|
101 | *
|
102 | * @default false
|
103 | */
|
104 | monitor?: boolean;
|
105 | /**
|
106 | * The commands that don't get a reply due to the connection to the server is lost are
|
107 | * put into a queue and will be resent on reconnect (if allowed by the `retryStrategy` option).
|
108 | * This option is used to configure how many reconnection attempts should be allowed before
|
109 | * the queue is flushed with a `MaxRetriesPerRequestError` error.
|
110 | * Set this options to `null` instead of a number to let commands wait forever
|
111 | * until the connection is alive again.
|
112 | *
|
113 | * @default 20
|
114 | */
|
115 | maxRetriesPerRequest?: number | null;
|
116 | /**
|
117 | * @default 10000
|
118 | */
|
119 | maxLoadingRetryTime?: number;
|
120 | /**
|
121 | * @default false
|
122 | */
|
123 | enableAutoPipelining?: boolean;
|
124 | /**
|
125 | * @default []
|
126 | */
|
127 | autoPipeliningIgnoredCommands?: string[];
|
128 | offlineQueue?: boolean;
|
129 | commandQueue?: boolean;
|
130 | /**
|
131 | *
|
132 | * By default, if the connection to Redis server has not been established, commands are added to a queue
|
133 | * and are executed once the connection is "ready" (when `enableReadyCheck` is true, "ready" means
|
134 | * the Redis server has loaded the database from disk, otherwise means the connection to the Redis
|
135 | * server has been established). If this option is false, when execute the command when the connection
|
136 | * isn't ready, an error will be returned.
|
137 | *
|
138 | * @default true
|
139 | */
|
140 | enableOfflineQueue?: boolean;
|
141 | /**
|
142 | * The client will sent an INFO command to check whether the server is still loading data from the disk (
|
143 | * which happens when the server is just launched) when the connection is established, and only wait until
|
144 | * the loading process is finished before emitting the `ready` event.
|
145 | *
|
146 | * @default true
|
147 | */
|
148 | enableReadyCheck?: boolean;
|
149 | /**
|
150 | * When a Redis instance is initialized, a connection to the server is immediately established. Set this to
|
151 | * true will delay the connection to the server until the first command is sent or `redis.connect()` is called
|
152 | * explicitly.
|
153 | *
|
154 | * @default false
|
155 | */
|
156 | lazyConnect?: boolean;
|
157 | /**
|
158 | * @default undefined
|
159 | */
|
160 | scripts?: Record<string, {
|
161 | lua: string;
|
162 | numberOfKeys?: number;
|
163 | readOnly?: boolean;
|
164 | }>;
|
165 | keyPrefix?: string;
|
166 | showFriendlyErrorStack?: boolean;
|
167 | disconnectTimeout?: number;
|
168 | tls?: ConnectionOptions;
|
169 | /**
|
170 | * Master group name of the Sentinel
|
171 | */
|
172 | name?: string;
|
173 | /**
|
174 | * @default "master"
|
175 | */
|
176 | role?: 'master' | 'slave';
|
177 | sentinelUsername?: string;
|
178 | sentinelPassword?: string;
|
179 | sentinels?: Array<Partial<any>>;
|
180 | sentinelRetryStrategy?: (retryAttempts: number) => number | void | null;
|
181 | sentinelReconnectStrategy?: (retryAttempts: number) => number | void | null;
|
182 | preferredSlaves?: any;
|
183 | sentinelCommandTimeout?: number;
|
184 | enableTLSForSentinelMode?: boolean;
|
185 | sentinelTLS?: ConnectionOptions;
|
186 | natMap?: any;
|
187 | updateSentinels?: boolean;
|
188 | |
189 |
|
190 |
|
191 | sentinelMaxConnections?: number;
|
192 | failoverDetector?: boolean;
|
193 | }
|