Skip to content

Commit 8dab27e

Browse files
authored
fix sentinel generics (#2859)
* fix sentinel generics * comment nit
1 parent 4708736 commit 8dab27e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/client/lib/sentinel/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ export class RedisSentinelClient<
9393
RESP extends RespVersions = 2,
9494
TYPE_MAPPING extends TypeMapping = {}
9595
>(
96+
options: RedisSentinelOptions<M, F, S, RESP, TYPE_MAPPING>,
9697
internal: RedisSentinelInternal<M, F, S, RESP, TYPE_MAPPING>,
9798
clientInfo: ClientInfo,
9899
commandOptions?: CommandOptions<TYPE_MAPPING>,
99-
options?: RedisSentinelOptions<M, F, S, RESP, TYPE_MAPPING>
100100
) {
101101
return RedisSentinelClient.factory(options)(internal, clientInfo, commandOptions);
102102
}
@@ -272,7 +272,7 @@ export default class RedisSentinel<
272272

273273
this.#options = options;
274274

275-
if (options?.commandOptions) {
275+
if (options.commandOptions) {
276276
this.#commandOptions = options.commandOptions;
277277
}
278278

@@ -307,7 +307,7 @@ export default class RedisSentinel<
307307

308308
Sentinel.prototype.Multi = RedisSentinelMultiCommand.extend(config);
309309

310-
return (options?: Omit<RedisSentinelOptions, keyof Exclude<typeof config, undefined>>) => {
310+
return (options: Omit<RedisSentinelOptions, keyof Exclude<typeof config, undefined>>) => {
311311
// returning a "proxy" to prevent the namespaces.self to leak between "proxies"
312312
return Object.create(new Sentinel(options)) as RedisSentinelType<M, F, S, RESP, TYPE_MAPPING>;
313313
};
@@ -319,7 +319,7 @@ export default class RedisSentinel<
319319
S extends RedisScripts = {},
320320
RESP extends RespVersions = 2,
321321
TYPE_MAPPING extends TypeMapping = {}
322-
>(options?: RedisSentinelOptions<M, F, S, RESP, TYPE_MAPPING>) {
322+
>(options: RedisSentinelOptions<M, F, S, RESP, TYPE_MAPPING>) {
323323
return RedisSentinel.factory(options)(options);
324324
}
325325

@@ -409,7 +409,7 @@ export default class RedisSentinel<
409409

410410
try {
411411
return await fn(
412-
RedisSentinelClient.create(this._self.#internal, clientInfo, this._self.#commandOptions, this._self.#options)
412+
RedisSentinelClient.create(this._self.#options, this._self.#internal, clientInfo, this._self.#commandOptions)
413413
);
414414
} finally {
415415
const promise = this._self.#internal.releaseClientLease(clientInfo);
@@ -510,7 +510,7 @@ export default class RedisSentinel<
510510

511511
async aquire(): Promise<RedisSentinelClientType<M, F, S, RESP, TYPE_MAPPING>> {
512512
const clientInfo = await this._self.#internal.getClientLease();
513-
return RedisSentinelClient.create(this._self.#internal, clientInfo, this._self.#commandOptions, this._self.#options);
513+
return RedisSentinelClient.create(this._self.#options, this._self.#internal, clientInfo, this._self.#commandOptions);
514514
}
515515

516516
getSentinelNode(): RedisNode | undefined {

packages/client/lib/sentinel/types.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ export interface RedisSentinelOptions<
2929
* The maximum number of times a command will retry due to topology changes.
3030
*/
3131
maxCommandRediscovers?: number;
32+
// TODO: omit properties that users shouldn't be able to specify for sentinel at this level
3233
/**
3334
* The configuration values for every node in the cluster. Use this for example when specifying an ACL user to connect with
3435
*/
35-
nodeClientOptions?: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING, RedisTcpSocketOptions>;
36+
nodeClientOptions?: RedisClientOptions<RedisModules, RedisFunctions, RedisScripts, RESP, TYPE_MAPPING, RedisTcpSocketOptions>;
37+
// TODO: omit properties that users shouldn't be able to specify for sentinel at this level
3638
/**
3739
* The configuration values for every sentinel in the cluster. Use this for example when specifying an ACL user to connect with
3840
*/
39-
sentinelClientOptions?: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING, RedisTcpSocketOptions>;
41+
sentinelClientOptions?: RedisClientOptions<RedisModules, RedisFunctions, RedisScripts, RESP, TYPE_MAPPING, RedisTcpSocketOptions>;
4042
/**
4143
* The number of clients connected to the master node
4244
*/

0 commit comments

Comments
 (0)