You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
chore: emit ready when all commands are done
This commit is contained in:
15
index.js
15
index.js
@@ -275,7 +275,7 @@ RedisClient.prototype.warn = function (msg) {
|
|||||||
RedisClient.prototype.flushAndError = function (errorAttributes, options) {
|
RedisClient.prototype.flushAndError = function (errorAttributes, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var aggregatedErrors = [];
|
var aggregatedErrors = [];
|
||||||
var queueNames = options.queues || ['commandQueue', 'offlineQueue']; // Flush the commandQueue first to keep the order intakt
|
var queueNames = options.queues || ['commandQueue', 'offlineQueue']; // Flush the commandQueue first to keep the order intact
|
||||||
for (var i = 0; i < queueNames.length; i++) {
|
for (var i = 0; i < queueNames.length; i++) {
|
||||||
// If the command was fired it might have been processed so far
|
// If the command was fired it might have been processed so far
|
||||||
if (queueNames[i] === 'commandQueue') {
|
if (queueNames[i] === 'commandQueue') {
|
||||||
@@ -386,23 +386,12 @@ RedisClient.prototype.onReady = function () {
|
|||||||
}
|
}
|
||||||
var callbackCount = Object.keys(this.subscriptionSet).length;
|
var callbackCount = Object.keys(this.subscriptionSet).length;
|
||||||
if (!this.options.disableResubscribing && callbackCount) {
|
if (!this.options.disableResubscribing && callbackCount) {
|
||||||
// only emit 'ready' when all subscriptions were made again
|
|
||||||
// TODO: Remove the countdown for ready here. This is not coherent with all other modes and should therefore not be handled special
|
|
||||||
// We know we are ready as soon as all commands were fired
|
|
||||||
var callback = function () {
|
|
||||||
callbackCount--;
|
|
||||||
if (callbackCount === 0) {
|
|
||||||
self.emit('ready');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
debug('Sending pub/sub onReady commands');
|
debug('Sending pub/sub onReady commands');
|
||||||
for (var key in this.subscriptionSet) {
|
for (var key in this.subscriptionSet) {
|
||||||
var command = key.slice(0, key.indexOf('_'));
|
var command = key.slice(0, key.indexOf('_'));
|
||||||
var args = this.subscriptionSet[key];
|
var args = this.subscriptionSet[key];
|
||||||
this[command]([args], callback);
|
this[command]([args]);
|
||||||
}
|
}
|
||||||
this.sendOfflineQueue();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
this.sendOfflineQueue();
|
this.sendOfflineQueue();
|
||||||
this.emit('ready');
|
this.emit('ready');
|
||||||
|
Reference in New Issue
Block a user