Skip to content

Commit

Permalink
fix sentinel generics (#2859)
Browse files Browse the repository at this point in the history
* fix sentinel generics

* comment nit
  • Loading branch information
sjpotter authored Nov 4, 2024
1 parent 4708736 commit 8dab27e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions packages/client/lib/sentinel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ export class RedisSentinelClient<
RESP extends RespVersions = 2,
TYPE_MAPPING extends TypeMapping = {}
>(
options: RedisSentinelOptions<M, F, S, RESP, TYPE_MAPPING>,
internal: RedisSentinelInternal<M, F, S, RESP, TYPE_MAPPING>,
clientInfo: ClientInfo,
commandOptions?: CommandOptions<TYPE_MAPPING>,
options?: RedisSentinelOptions<M, F, S, RESP, TYPE_MAPPING>
) {
return RedisSentinelClient.factory(options)(internal, clientInfo, commandOptions);
}
Expand Down Expand Up @@ -272,7 +272,7 @@ export default class RedisSentinel<

this.#options = options;

if (options?.commandOptions) {
if (options.commandOptions) {
this.#commandOptions = options.commandOptions;
}

Expand Down Expand Up @@ -307,7 +307,7 @@ export default class RedisSentinel<

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

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

Expand Down Expand Up @@ -409,7 +409,7 @@ export default class RedisSentinel<

try {
return await fn(
RedisSentinelClient.create(this._self.#internal, clientInfo, this._self.#commandOptions, this._self.#options)
RedisSentinelClient.create(this._self.#options, this._self.#internal, clientInfo, this._self.#commandOptions)
);
} finally {
const promise = this._self.#internal.releaseClientLease(clientInfo);
Expand Down Expand Up @@ -510,7 +510,7 @@ export default class RedisSentinel<

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

getSentinelNode(): RedisNode | undefined {
Expand Down
6 changes: 4 additions & 2 deletions packages/client/lib/sentinel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ export interface RedisSentinelOptions<
* The maximum number of times a command will retry due to topology changes.
*/
maxCommandRediscovers?: number;
// TODO: omit properties that users shouldn't be able to specify for sentinel at this level
/**
* The configuration values for every node in the cluster. Use this for example when specifying an ACL user to connect with
*/
nodeClientOptions?: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING, RedisTcpSocketOptions>;
nodeClientOptions?: RedisClientOptions<RedisModules, RedisFunctions, RedisScripts, RESP, TYPE_MAPPING, RedisTcpSocketOptions>;
// TODO: omit properties that users shouldn't be able to specify for sentinel at this level
/**
* The configuration values for every sentinel in the cluster. Use this for example when specifying an ACL user to connect with
*/
sentinelClientOptions?: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING, RedisTcpSocketOptions>;
sentinelClientOptions?: RedisClientOptions<RedisModules, RedisFunctions, RedisScripts, RESP, TYPE_MAPPING, RedisTcpSocketOptions>;
/**
* The number of clients connected to the master node
*/
Expand Down

0 comments on commit 8dab27e

Please sign in to comment.