1
0
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:
Matt Ranney
2010-11-09 13:13:40 -08:00
parent e6f7dc5f20
commit 1eb3f6a1aa
4 changed files with 31 additions and 1 deletions

View File

@@ -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") {