diff --git a/lib/connectors/sentinel_connector.js b/lib/connectors/sentinel_connector.js index a4bb5af9..30b168e0 100644 --- a/lib/connectors/sentinel_connector.js +++ b/lib/connectors/sentinel_connector.js @@ -99,10 +99,8 @@ SentinelConnector.prototype.updateSentinels = function (client, callback) { var sentinel = utils.packObject(result[i]); var flags = sentinel.flags ? sentinel.flags.split(',') : []; if (flags.indexOf('disconnected') === -1 && sentinel.ip && sentinel.port) { - var endpoint = { host: sentinel.ip, port: parseInt(sentinel.port) }; - var isDuplicate = _this.sentinels.some(function (o) { - return o.host === endpoint.host && o.port === endpoint.port; - }); + var endpoint = { host: sentinel.ip, port: parseInt(sentinel.port, 10) }; + var isDuplicate = _this.sentinels.some(_.bind(isSentinelEql, null, endpoint)); if (!isDuplicate) { debug('adding sentinel %s:%s', endpoint.host, endpoint.port); _this.sentinels.push(endpoint); @@ -178,4 +176,9 @@ SentinelConnector.prototype.resolve = function (endpoint, callback) { function noop() {} +function isSentinelEql(a, b) { + return ((a.host || '127.0.0.1') === (b.host || '127.0.0.1')) && + ((a.port || 6379) === (b.port || 6379)); +} + module.exports = SentinelConnector;