Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sorting on runid for consitent slave upgrades across mutlple proxies

  • Loading branch information...
commit ce831c133c92573645f9e39d53582cc82a095ad5 1 parent 9d31a43
@sreeix authored
Showing with 8 additions and 6 deletions.
  1. +1 −1  config/config.json
  2. +6 −4 lib/redis_proxy.js
  3. +1 −1  package.json
View
2  config/config.json
@@ -1,7 +1,7 @@
{
"servers": [{
"host": "localhost"
- ,"port": 6379
+ ,"port": 6399
}
, {
"host": "localhost"
View
10 lib/redis_proxy.js
@@ -23,7 +23,7 @@ var RedisProxy = module.exports = function(o){
this.options = _.defaults(o, {listen_port: 6379, softErrorCount: 5, pool_size: 10, mode: "allToMaster"});
if(o.servers && o.servers.size === 0)
- throw new Error("Expected to have at least one redis to proxy");
+ throw new Error("Expected to have at least one redis to proxy. Can't start");
this.sendCommand = this[this.options.mode];
logger.info("Using the "+ this.options.mode +" mode.");
@@ -70,9 +70,11 @@ RedisProxy.prototype.readyup = function(active){
};
RedisProxy.prototype.nextActive = function() {
- this._active = _.find(this.allServers, function(server) {
- return server.isUp();
- });
+ this._active = _.chain(this.allServers).select(function(server) {
+ return server.isUp() && server.client.server_info["slave-priority"] !== "0";
+ }).sortBy(function (server) {
+ return server.client.server_info["runid"] ;
+ }).first().value();
if(this._active){
this.readyup(this.active);
View
2  package.json
@@ -23,7 +23,7 @@
, "hiredis": ""
, "connection_pool": "0.0.2"
, "node-redis-raw": "0.0.2"
- , "redis": "0.7.1"
+ , "redis": "0.8.2"
}
, "devDependencies": {
"mocha": "0.0.8"
Please sign in to comment.
Something went wrong with that request. Please try again.