Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue where on failure, callback would be called multiple times #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions sharded-redis-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ shardable.forEach(function(cmd){
var key = Array.isArray(arguments[0]) ? arguments[0][0] : arguments[0];

var client = this._findMatchedClient(key, cmd);

var startIndex = client._rrindex;
var commandFn = client[cmd];
var wrappedClient = self._getWrappedClient(key);
Expand All @@ -192,7 +191,7 @@ shardable.forEach(function(cmd){
if (client._rrindex == startIndex) {
client = self._findMasterClient(key);
}
commandFn.apply(client, args);
return commandFn.apply(client, args);
}
mainCb.apply(this, arguments);
};
Expand Down Expand Up @@ -243,7 +242,10 @@ function WrappedClient (conf, use_ping) {
var client = create_client(conf.port, conf.host, use_ping);

var slaveClients = conf.slaves.map(function(slaveHost){
return create_client(conf.port, slaveHost, use_ping);
if(slaveHost.host && slaveHost.port)
return create_client(slaveHost.port, slaveHost.host, use_ping);
else
return create_client(conf.port, slaveHost, use_ping);
});

if (!slaveClients.length) {
Expand Down