Skip to content

fix cluster.sUnsubscribe - make listener optional #2641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/client/lib/cluster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export interface RedisClusterOptions<
S extends RedisScripts = Record<string, never>
> extends RedisExtensions<M, F, S> {
/**
* Should contain details for some of the cluster nodes that the client will use to discover
* Should contain details for some of the cluster nodes that the client will use to discover
* the "cluster topology". We recommend including details for at least 3 nodes here.
*/
rootNodes: Array<RedisClusterClientOptions>;
/**
* Default values used for every client in the cluster. Use this to specify global values,
* Default values used for every client in the cluster. Use this to specify global values,
* for example: ACL credentials, timeouts, TLS configuration etc.
*/
defaults?: Partial<RedisClusterClientOptions>;
Expand All @@ -45,7 +45,7 @@ export interface RedisClusterOptions<
/**
* Mapping between the addresses in the cluster (see `CLUSTER SHARDS`) and the addresses the client should connect to
* Useful when the cluster is running on another network
*
*
*/
nodeAddressMap?: NodeAddressMap;
}
Expand Down Expand Up @@ -98,7 +98,7 @@ export default class RedisCluster<
readonly #options: RedisClusterOptions<M, F, S>;

readonly #slots: RedisClusterSlots<M, F, S>;

get slots() {
return this.#slots.slots;
}
Expand Down Expand Up @@ -310,7 +310,7 @@ export default class RedisCluster<
listener?: PubSubListener<boolean>,
bufferMode?: T
) {
return this.#slots.executeUnsubscribeCommand(client =>
return this.#slots.executeUnsubscribeCommand(client =>
client.UNSUBSCRIBE(channels, listener, bufferMode)
);
}
Expand All @@ -333,7 +333,7 @@ export default class RedisCluster<
listener?: PubSubListener<T>,
bufferMode?: T
) {
return this.#slots.executeUnsubscribeCommand(client =>
return this.#slots.executeUnsubscribeCommand(client =>
client.PUNSUBSCRIBE(patterns, listener, bufferMode)
);
}
Expand All @@ -344,7 +344,7 @@ export default class RedisCluster<
channels: string | Array<string>,
listener: PubSubListener<T>,
bufferMode?: T
) {
) {
const maxCommandRedirections = this.#options.maxCommandRedirections ?? 16,
firstChannel = Array.isArray(channels) ? channels[0] : channels;
let client = await this.#slots.getShardedPubSubClient(firstChannel);
Expand All @@ -371,7 +371,7 @@ export default class RedisCluster<

SUNSUBSCRIBE<T extends boolean = false>(
channels: string | Array<string>,
listener: PubSubListener<T>,
listener?: PubSubListener<T>,
bufferMode?: T
) {
return this.#slots.executeShardedUnsubscribeCommand(
Expand All @@ -391,7 +391,7 @@ export default class RedisCluster<
}

nodeClient(node: ShardNode<M, F, S>) {
return this.#slots.nodeClient(node);
return this.#slots.nodeClient(node);
}

getRandomNode() {
Expand Down