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 disable_resubscribingg option. Fixes #472
This commit is contained in:
@@ -203,6 +203,7 @@ That way the default is to try reconnecting until 24h passed.
|
|||||||
limits total amount of connection tries. Setting this to 1 will prevent any reconnect tries.
|
limits total amount of connection tries. Setting this to 1 will prevent any reconnect tries.
|
||||||
* `auth_pass` *null*; If set, client will run redis auth command on connect.
|
* `auth_pass` *null*; If set, client will run redis auth command on connect.
|
||||||
* `family` *IPv4*; You can force using IPv6 if you set the family to 'IPv6'. See Node.js [net](https://nodejs.org/api/net.html) or [dns](https://nodejs.org/api/dns.html) modules how to use the family type.
|
* `family` *IPv4*; You can force using IPv6 if you set the family to 'IPv6'. See Node.js [net](https://nodejs.org/api/net.html) or [dns](https://nodejs.org/api/dns.html) modules how to use the family type.
|
||||||
|
* `disable_resubscribing`: *false*; If set to `true`, a client won't resubscribe after disconnecting
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var redis = require("redis"),
|
var redis = require("redis"),
|
||||||
|
14
changelog.md
14
changelog.md
@@ -1,6 +1,16 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
## v.2.x.x - xx, 2015
|
||||||
|
|
||||||
|
Features
|
||||||
|
|
||||||
|
- Added disable_resubscribing option to prevent a client from resubscribing after reconnecting (@BridgeAR)
|
||||||
|
|
||||||
|
Bugfixes
|
||||||
|
|
||||||
|
-
|
||||||
|
|
||||||
## v2.1.0 - Oct 02, 2015
|
## v2.1.0 - Oct 02, 2015
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
@@ -14,7 +24,7 @@ Bugfixes:
|
|||||||
- Fix argument mutation while using the array notation with the multi constructor (@BridgeAR)
|
- Fix argument mutation while using the array notation with the multi constructor (@BridgeAR)
|
||||||
- Fix multi.hmset key not being type converted if used with an object and key not being a string (@BridgeAR)
|
- Fix multi.hmset key not being type converted if used with an object and key not being a string (@BridgeAR)
|
||||||
- Fix parser errors not being catched properly (@BridgeAR)
|
- Fix parser errors not being catched properly (@BridgeAR)
|
||||||
- Fix a crash that could occur if a redis server does return the info command as usual #541 (@BridgeAR)
|
- Fix a crash that could occur if a redis server does not return the info command as usual #541 (@BridgeAR)
|
||||||
- Explicitly passing undefined as a callback statement will work again. E.g. client.publish('channel', 'message', undefined); (@BridgeAR)
|
- Explicitly passing undefined as a callback statement will work again. E.g. client.publish('channel', 'message', undefined); (@BridgeAR)
|
||||||
|
|
||||||
## v2.0.1 - Sep 24, 2015
|
## v2.0.1 - Sep 24, 2015
|
||||||
@@ -27,7 +37,7 @@ Bugfixes:
|
|||||||
|
|
||||||
This is the biggest release that node_redis had since it was released in 2010. A long list of outstanding bugs has been fixed, so we are very happy to present you redis 2.0 and we highly recommend updating as soon as possible.
|
This is the biggest release that node_redis had since it was released in 2010. A long list of outstanding bugs has been fixed, so we are very happy to present you redis 2.0 and we highly recommend updating as soon as possible.
|
||||||
|
|
||||||
#What's new in 2.0
|
# What's new in 2.0
|
||||||
|
|
||||||
- Implemented a "connection is broken" mode if no connection could be established
|
- Implemented a "connection is broken" mode if no connection could be established
|
||||||
- node_redis no longer throws under any circumstances, preventing it from terminating applications.
|
- node_redis no longer throws under any circumstances, preventing it from terminating applications.
|
||||||
|
3
index.js
3
index.js
@@ -318,6 +318,9 @@ RedisClient.prototype.on_ready = function () {
|
|||||||
self.emit("ready");
|
self.emit("ready");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (this.options.disable_resubscribing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Object.keys(this.subscription_set).forEach(function (key) {
|
Object.keys(this.subscription_set).forEach(function (key) {
|
||||||
var space_index = key.indexOf(" ");
|
var space_index = key.indexOf(" ");
|
||||||
var parts = [key.slice(0, space_index), key.slice(space_index + 1)];
|
var parts = [key.slice(0, space_index), key.slice(space_index + 1)];
|
||||||
|
@@ -26,20 +26,67 @@ describe("publish/subscribe", function () {
|
|||||||
pub.once("connect", function () {
|
pub.once("connect", function () {
|
||||||
pub.flushdb(function () {
|
pub.flushdb(function () {
|
||||||
pubConnected = true;
|
pubConnected = true;
|
||||||
|
if (subConnected) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
sub.once("error", done);
|
sub.once("error", done);
|
||||||
sub.once("connect", function () {
|
sub.once("connect", function () {
|
||||||
subConnected = true;
|
subConnected = true;
|
||||||
|
if (pubConnected) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('disable resubscribe', function () {
|
||||||
|
beforeEach(function (done) {
|
||||||
|
var pubConnected;
|
||||||
|
var subConnected;
|
||||||
|
|
||||||
|
pub = redis.createClient();
|
||||||
|
sub = redis.createClient({
|
||||||
|
disable_resubscribing: false
|
||||||
|
});
|
||||||
|
pub.once("error", done);
|
||||||
|
pub.once("connect", function () {
|
||||||
|
pubConnected = true;
|
||||||
|
if (subConnected) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
sub.once("error", done);
|
||||||
|
sub.once("connect", function () {
|
||||||
|
subConnected = true;
|
||||||
|
if (pubConnected) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var id = setInterval(function () {
|
it('does not fire subscribe events after reconnecting', function (done) {
|
||||||
if (pubConnected && subConnected) {
|
var a = false;
|
||||||
clearInterval(id);
|
sub.on("subscribe", function (chnl, count) {
|
||||||
return done();
|
if (chnl === channel2) {
|
||||||
}
|
if (a) {
|
||||||
}, 50);
|
return done(new Error('Test failed'));
|
||||||
|
}
|
||||||
|
assert.equal(2, count);
|
||||||
|
sub.stream.destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
sub.on('reconnecting', function() {
|
||||||
|
a = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
sub.subscribe(channel, channel2);
|
||||||
|
|
||||||
|
setTimeout(done, 250);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('subscribe', function () {
|
describe('subscribe', function () {
|
||||||
|
Reference in New Issue
Block a user