Skip to content

Commit 8557f04

Browse files
committed
expose new options
1 parent d1fc1f0 commit 8557f04

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

packages/client/lib/client/index.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,44 @@ export interface RedisClientOptions<
144144
* Tag to append to library name that is sent to the Redis server
145145
*/
146146
clientInfoTag?: string;
147+
148+
/**
149+
* Configuration for handling Redis Enterprise graceful maintenance scenarios.
150+
*
151+
* When Redis Enterprise performs maintenance operations, nodes will be replaced, resulting in disconnects.
152+
* This configuration allows the client to handle these scenarios gracefully by automatically
153+
* reconnecting and managing command execution during maintenance windows.
154+
*
155+
* @example Basic graceful maintenance configuration
156+
* ```
157+
* const client = createClient({
158+
* gracefulMaintenance: {
159+
* handleFailedCommands: 'retry',
160+
* handleTimeouts: 'exception',
161+
* }
162+
* });
163+
* ```
164+
*
165+
* @example Graceful maintenance with timeout smoothing
166+
* ```
167+
* const client = createClient({
168+
* gracefulMaintenance: {
169+
* handleFailedCommands: 'retry',
170+
* handleTimeouts: 5000, // Extend timeouts to 5 seconds during maintenance
171+
* }
172+
* });
173+
* ```
174+
*/
175+
gracefulMaintenance?: {
176+
/**
177+
* Designates how failed commands should be handled. A failed command is when the time isn’t sufficient to deal with the responses on the old connection before the server shuts it down
178+
*/
179+
handleFailedCommands: 'exception' | 'retry',
180+
/**
181+
* Specify whether we should throw a MaintenanceTimeout exception or provide more relaxed timeout, in order to minimize command timeouts during maintenance.
182+
*/
183+
handleTimeouts: 'exception' | number,
184+
}
147185
}
148186

149187
type WithCommands<
@@ -468,6 +506,10 @@ export default class RedisClient<
468506
throw new Error('Client Side Caching is only supported with RESP3');
469507
}
470508

509+
if (options?.gracefulMaintenance && options?.RESP !== 3) {
510+
throw new Error('Graceful Maintenance is only supported with RESP3');
511+
}
512+
471513
}
472514
#initiateOptions(options?: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING>): RedisClientOptions<M, F, S, RESP, TYPE_MAPPING> | undefined {
473515

0 commit comments

Comments
 (0)