many tests

This commit is contained in:
Spencer Alger
2013-12-03 19:01:04 -07:00
parent 2ddde47972
commit 4e5f08a29c
19 changed files with 1011 additions and 201 deletions

View File

@ -28,6 +28,9 @@ function Transport(config) {
var Serializer = _.funcEnum(config, 'serializer', Transport.serializers, 'json');
this.serializer = new Serializer(config);
// setup the nodesToHostCallback
this.nodesToHostCallback = _.funcEnum(config, 'nodesToHostCallback', Transport.nodesToHostCallbacks, 'main');
// setup max retries
this.maxRetries = config.hasOwnProperty('maxRetries') ? config.maxRetries : 3;
@ -209,7 +212,8 @@ Transport.prototype.createDefer = function () {
* @param {Function} cb - Function to call back once complete
*/
Transport.prototype.sniff = function (cb) {
var self = this;
var connectionPool = this.connectionPool;
var nodesToHostCallback = this.nodesToHostCallback;
// make cb a function if it isn't
cb = typeof cb === 'function' ? cb : _.noop;
@ -217,14 +221,14 @@ Transport.prototype.sniff = function (cb) {
this.request({
path: '/_cluster/nodes',
method: 'GET'
}, function (err, resp) {
}, function (err, resp, status) {
if (!err && resp && resp.nodes) {
var hosts = _.map(self.nodesToHostCallback(resp.nodes), function (hostConfig) {
var hosts = _.map(nodesToHostCallback(resp.nodes), function (hostConfig) {
return new Host(hostConfig);
});
this.connectionPool.setHosts(hosts);
connectionPool.setHosts(hosts);
}
cb(err, resp);
cb(err, resp, status);
});
};