[Pkg-javascript-commits] [node-node-redis] 12/19: Imported Upstream version 0.1.7

Mike Gabriel sunweaver at debian.org
Wed Aug 20 13:18:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

sunweaver pushed a commit to branch master
in repository node-node-redis.

commit 3bd222efbb6b7064d2ffbded5bf083821be55fe9
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Aug 20 15:10:06 2014 +0200

    Imported Upstream version 0.1.7
---
 index.js     | 30 +++++++++++++++++++++++++++---
 package.json |  4 ++--
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/index.js b/index.js
index 0967c44..be65294 100644
--- a/index.js
+++ b/index.js
@@ -29,7 +29,7 @@ var RedisClient = function RedisClient(port, host, auth) {
   this.host           = host;
   this.port           = port;
   this.auth           = auth;
-  this.stream         = net.createConnection(port, host);;
+  this.stream         = net.createConnection(port, host);
   this.connected      = false;
   // Pub/sub monitor etc.
   this.blocking       = false;
@@ -48,6 +48,8 @@ var RedisClient = function RedisClient(port, host, auth) {
   this.paused         = false;
   this.send_buffer    = [];
   this.flushing       = false;
+  // channels / patterns for disconnects
+  this.pubsub         = { pattern : {}, channel : {} }
 
   var self = this;
 
@@ -76,6 +78,17 @@ var RedisClient = function RedisClient(port, host, auth) {
       self.sendCommand(command[0], command[1], command[2]);
     }
 
+    // pubsub?
+    var patterns = Object.keys(self.pubsub.pattern)
+    var channels = Object.keys(self.pubsub.channel)
+
+    for (var i = 0, il = patterns.length; i < il; i++) {
+      self.psubscribe(patterns[i])
+    }
+    for (var i = 0, il = channels.length; i < il; i++) {
+      self.subscribe(channels[i])
+    }
+
     // give connect listeners a chance to run first in case they need to auth
     self.emit("connect");
   });
@@ -112,6 +125,7 @@ var RedisClient = function RedisClient(port, host, auth) {
   this.stream.on('drain', this._flush);
 
   this.stream.on("error", function (error) {
+    if ('ECONNREFUSED' === error.code) self.onDisconnect()
     self.emit("error", error);
   });
 
@@ -151,6 +165,18 @@ var RedisClient = function RedisClient(port, host, auth) {
 
           if (0 === count) {
             self.blocking = false;
+
+            if ('punsubscribe' === type) {
+              delete self.pubsub.pattern[channel]
+            } else if ('unsubscribe' === type) {
+              delete self.pubsub.channel[channel]
+            }
+          }
+
+          if ('psubscribe' === type) {
+            self.pubsub.pattern[channel] = true
+          } else if ('subscribe' === type) {
+            self.pubsub.channel[channel] = true
           }
 
           self.emit(type, channel, count);
@@ -204,8 +230,6 @@ var RedisClient = function RedisClient(port, host, auth) {
   });
 
   process.EventEmitter.call(this);
-
-  return this;
 };
 
 RedisClient.prototype = Object.create(process.EventEmitter.prototype);
diff --git a/package.json b/package.json
index a594898..f283901 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "node-redis",
   "description": "Lightweight, fast, Redis client.",
-  "version": "0.1.6",
+  "version": "0.1.7",
   "author": "Tim Smart",
   "contributors": [
     "Matt Ranney"
@@ -10,6 +10,6 @@
     "type": "git",
     "url": "http://github.com/Tim-Smart/node-redis.git"
   },
-  "engine": [ "node >=0.2.2" ],
+  "engine": [ "node >=0.8" ],
   "main": "./"
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-node-redis.git



More information about the Pkg-javascript-commits mailing list