You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
use asap fro pubsub resubscribe
This commit is contained in:
@@ -223,7 +223,7 @@ export default class RedisCommandsQueue {
|
||||
listener: PubSubListener<T>,
|
||||
returnBuffers?: T
|
||||
) {
|
||||
return this._pushPubSubCommand(
|
||||
return this._addPubSubCommand(
|
||||
this._pubSub.subscribe(type, channels, listener, returnBuffers)
|
||||
);
|
||||
}
|
||||
@@ -234,7 +234,7 @@ export default class RedisCommandsQueue {
|
||||
listener?: PubSubListener<T>,
|
||||
returnBuffers?: T
|
||||
) {
|
||||
return this._pushPubSubCommand(
|
||||
return this._addPubSubCommand(
|
||||
this._pubSub.unsubscribe(type, channels, listener, returnBuffers)
|
||||
);
|
||||
}
|
||||
@@ -244,7 +244,7 @@ export default class RedisCommandsQueue {
|
||||
if (!commands.length) return;
|
||||
|
||||
return Promise.all(
|
||||
commands.map(command => this._pushPubSubCommand(command))
|
||||
commands.map(command => this._addPubSubCommand(command, true))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -253,13 +253,13 @@ export default class RedisCommandsQueue {
|
||||
channel: string,
|
||||
listeners: ChannelListeners
|
||||
) {
|
||||
return this._pushPubSubCommand(
|
||||
return this._addPubSubCommand(
|
||||
this._pubSub.extendChannelListeners(type, channel, listeners)
|
||||
);
|
||||
}
|
||||
|
||||
extendPubSubListeners(type: PubSubType, listeners: PubSubTypeListeners) {
|
||||
return this._pushPubSubCommand(
|
||||
return this._addPubSubCommand(
|
||||
this._pubSub.extendTypeListeners(type, listeners)
|
||||
);
|
||||
}
|
||||
@@ -268,11 +268,11 @@ export default class RedisCommandsQueue {
|
||||
return this._pubSub.getTypeListeners(type);
|
||||
}
|
||||
|
||||
private _pushPubSubCommand(command: PubSubCommand) {
|
||||
private _addPubSubCommand(command: PubSubCommand, asap = false) {
|
||||
if (command === undefined) return;
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
this._toWrite.push({
|
||||
(asap ? this._toWrite.unshift : this._toWrite.push)({
|
||||
args: command.args,
|
||||
chainId: undefined,
|
||||
abort: undefined,
|
||||
|
@@ -335,7 +335,7 @@ export default class RedisClient<
|
||||
|
||||
private _initiateSocket(): RedisSocket {
|
||||
const socketInitiator = async (): Promise<void> => {
|
||||
const promises = [];
|
||||
const promises = [this._queue.resubscribe()];
|
||||
|
||||
if (this._monitorCallback) {
|
||||
promises.push(
|
||||
@@ -408,11 +408,6 @@ export default class RedisClient<
|
||||
}
|
||||
}
|
||||
|
||||
const resubscribePromise = this._queue.resubscribe();
|
||||
if (resubscribePromise) {
|
||||
promises.push(resubscribePromise);
|
||||
}
|
||||
|
||||
if (promises.length) {
|
||||
this._write();
|
||||
await Promise.all(promises);
|
||||
|
Reference in New Issue
Block a user