You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Add "drain" and "idle" events.
This commit is contained in:
12
index.js
12
index.js
@@ -435,6 +435,10 @@ function RedisClient(stream) {
|
||||
self.connection_gone("end");
|
||||
});
|
||||
|
||||
this.stream.on("drain", function () {
|
||||
self.emit("drain");
|
||||
});
|
||||
|
||||
events.EventEmitter.call(this);
|
||||
}
|
||||
util.inherits(RedisClient, events.EventEmitter);
|
||||
@@ -505,6 +509,10 @@ RedisClient.prototype.on_data = function (data) {
|
||||
RedisClient.prototype.return_error = function (err) {
|
||||
var command_obj = this.command_queue.shift();
|
||||
|
||||
if (this.subscriptions === false && this.command_queue.length === 0) {
|
||||
this.emit("idle");
|
||||
}
|
||||
|
||||
if (command_obj && typeof command_obj.callback === "function") {
|
||||
command_obj.callback(err);
|
||||
} else {
|
||||
@@ -517,6 +525,10 @@ RedisClient.prototype.return_error = function (err) {
|
||||
RedisClient.prototype.return_reply = function (reply) {
|
||||
var command_obj = this.command_queue.shift(),
|
||||
obj, i, len, key, val, type;
|
||||
|
||||
if (this.subscriptions === false && this.command_queue.length === 0) {
|
||||
this.emit("idle");
|
||||
}
|
||||
|
||||
if (command_obj) {
|
||||
if (typeof command_obj.callback === "function") {
|
||||
|
Reference in New Issue
Block a user