Skip to content

Commit 724f0e0

Browse files
committed
feat(client): Add Redis Enterprise maintenance configuration options
- Introduced `maintPushNotifications` option to control how the client handles Redis Enterprise maintenance push notifications (`disabled`, `enabled`, `auto`). - Added `maintMovingEndpointType` option to specify the endpoint type for reconnecting during a MOVING notification (`auto`, `internal-ip`, `external-ip`, etc.). - Added `maintRelaxedCommandTimeout` option to define a relaxed timeout for commands during maintenance. - Added `maintRelaxedSocketTimeout` option to define a relaxed timeout for the socket during maintenance. - Enforced RESP3 requirement for maintenance-related features (`maintPushNotifications`).
1 parent cc95b3d commit 724f0e0

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

packages/client/lib/client/index.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,46 @@ export interface RedisClientOptions<
144144
* Tag to append to library name that is sent to the Redis server
145145
*/
146146
clientInfoTag?: string;
147-
}
147+
/**
148+
* Controls how the client handles Redis Enterprise maintenance push notifications.
149+
*
150+
* - `disabled`: The feature is not used by the client.
151+
* - `enabled`: The client attempts to enable the feature on the server. If the server responds with an error, the connection is interrupted.
152+
* - `auto`: The client attempts to enable the feature on the server. If the server returns an error, the client disables the feature and continues.
153+
*
154+
* The default is `auto`.
155+
*/
156+
maintPushNotifications?: 'disabled' | 'enabled' | 'auto';
157+
/**
158+
* Controls how the client requests the endpoint to reconnect to during a MOVING notification in Redis Enterprise maintenance.
159+
*
160+
* - `auto`: If the connection is opened to a name or IP address that is from/resolves to a reserved private IP range, request an internal endpoint (e.g., internal-ip), otherwise an external one. If TLS is enabled, then request a FQDN.
161+
* - `internal-ip`: Enforce requesting the internal IP.
162+
* - `internal-fqdn`: Enforce requesting the internal FQDN.
163+
* - `external-ip`: Enforce requesting the external IP address.
164+
* - `external-fqdn`: Enforce requesting the external FQDN.
165+
* - `none`: Used to request a null endpoint, which tells the client to reconnect based on its current config
166+
167+
* The default is `auto`.
168+
*/
169+
maintMovingEndpointType?: MovingEndpointType;
170+
/**
171+
* Specifies a more relaxed timeout (in milliseconds) for commands during a maintenance window.
172+
* This helps minimize command timeouts during maintenance. If not provided, the `commandOptions.timeout`
173+
* will be used instead. Timeouts during maintenance period result in a `CommandTimeoutDuringMaintanance` error.
174+
*
175+
* The default is 10000
176+
*/
177+
maintRelaxedCommandTimeout?: number;
178+
/**
179+
* Specifies a more relaxed timeout (in milliseconds) for the socket during a maintenance window.
180+
* This helps minimize socket timeouts during maintenance. If not provided, the `socket.timeout`
181+
* will be used instead. Timeouts during maintenance period result in a `SocketTimeoutDuringMaintanance` error.
182+
*
183+
* The default is 10000
184+
*/
185+
maintRelaxedSocketTimeout?: number;
186+
};
148187

149188
type WithCommands<
150189
RESP extends RespVersions,
@@ -485,7 +524,12 @@ export default class RedisClient<
485524
throw new Error('Client Side Caching is only supported with RESP3');
486525
}
487526

527+
if (options?.maintPushNotifications && options?.maintPushNotifications !== 'disabled' && options?.RESP !== 3) {
528+
throw new Error('Graceful Maintenance is only supported with RESP3');
529+
}
530+
488531
}
532+
489533
#initiateOptions(options?: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING>): RedisClientOptions<M, F, S, RESP, TYPE_MAPPING> | undefined {
490534

491535
// Convert username/password to credentialsProvider if no credentialsProvider is already in place

0 commit comments

Comments
 (0)