Skip to content

Commit

Permalink
Merge pull request #28 from kiri-tech/master
Browse files Browse the repository at this point in the history
redis sentinel connection 支持密码
  • Loading branch information
xuduo authored Aug 11, 2017
2 parents 989af54 + 81f8e1b commit b61ab19
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions socket.io-push-redis/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function SimpleRedisHashCluster(config) {
this.sub = getClientsFromIpList(config.sub, this);
} else {
logger.debug("sub using sentinel", config.sub);
this.sub = getClientsFromSentinel(config.sub.sentinel, config.sub.groupName, REDIS_SLAVE, this);
this.sub = getClientsFromSentinel(config.sub.sentinel, config.sub.groupName, config.sub.password, REDIS_SLAVE, this);
}
}

Expand All @@ -47,20 +47,21 @@ function SimpleRedisHashCluster(config) {
self.pubs.push(getClientsFromIpList(pub));
} else {
logger.debug("pub using sentinel", pub);
self.pubs.push(getClientsFromSentinel(pub.sentinel, pub.groupName, REDIS_MASTER));
self.pubs.push(getClientsFromSentinel(pub.sentinel, pub.groupName, pub.password, REDIS_MASTER));
}
});
}
}

function getClientsFromSentinel(sentinels, names, role, subscribe) {
function getClientsFromSentinel(sentinels, names, password, role, subscribe) {
const clients = [];
if (names) {
names.forEach(function (name) {
const client = new IoRedis({
sentinels: sentinels,
name: name,
role: role,
password: password,
retryStrategy: function (times) {
const delay = Math.min(times * 300, 2000);
return delay;
Expand Down

0 comments on commit b61ab19

Please sign in to comment.