Merge pull request #56 from elasticsearch/master
Fix minSockets config option
This commit is contained in:
@ -36,7 +36,9 @@ function HttpConnector(host, config) {
|
||||
config = _.defaults(config || {}, {
|
||||
keepAlive: true,
|
||||
minSockets: 10,
|
||||
maxSockets: 10
|
||||
// 10 makes sense but 11 actually keeps 10 sockets around
|
||||
// https://github.com/mikeal/forever-agent/issues/8
|
||||
maxSockets: 11
|
||||
});
|
||||
|
||||
var Agent = this.hand.Agent; // the class
|
||||
@ -50,7 +52,8 @@ function HttpConnector(host, config) {
|
||||
}
|
||||
|
||||
this.agent = new Agent({
|
||||
maxSockets: config.maxSockets
|
||||
maxSockets: config.maxSockets,
|
||||
minSockets: config.minSockets
|
||||
});
|
||||
}
|
||||
_.inherits(HttpConnector, ConnectionAbstract);
|
||||
|
||||
54
test/unit/browser_builds/angular.js
vendored
54
test/unit/browser_builds/angular.js
vendored
@ -9,6 +9,21 @@ describe('Angular esFactory', function () {
|
||||
});
|
||||
|
||||
var uuid = (function () { var i = 0; return function () { return ++i; }; }());
|
||||
|
||||
/**
|
||||
* Perform promise based async code in a way that mocha will understand
|
||||
* @param {Function} cb - node style callback
|
||||
* @param {Function} body - function that executes async and returns a promise/value
|
||||
*/
|
||||
var prom = function (cb, body) {
|
||||
expect(cb).to.be.a('function');
|
||||
expect(body).to.be.a('function');
|
||||
|
||||
var promise = body();
|
||||
expect(promise.then).to.be.a('function');
|
||||
promise.then(function () { cb(); }, cb);
|
||||
};
|
||||
|
||||
function directive(makeDirective) {
|
||||
var root = document.createElement('div');
|
||||
root.setAttribute('ng-controller', 'empty-controller');
|
||||
@ -37,6 +52,7 @@ describe('Angular esFactory', function () {
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
it('has Transport and ConnectionPool properties', function (done) {
|
||||
directive(function (esFactory) {
|
||||
return function () {
|
||||
@ -46,11 +62,15 @@ describe('Angular esFactory', function () {
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
it('returns a new client when it is called', function (done) {
|
||||
directive(function (esFactory) {
|
||||
return function () {
|
||||
try {
|
||||
var client = esFactory({ hosts: null });
|
||||
var client = esFactory({
|
||||
hosts: null
|
||||
});
|
||||
|
||||
expect(client).to.have.keys('transport');
|
||||
expect(client.transport).to.be.a(esFactory.Transport);
|
||||
client.close();
|
||||
@ -61,16 +81,36 @@ describe('Angular esFactory', function () {
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error created by calling a method incorrectly', function (done) {
|
||||
directive(function (esFactory) {
|
||||
return function () {
|
||||
var client = esFactory({ hosts: null });
|
||||
prom(done, function () {
|
||||
var client = esFactory({ hosts: null });
|
||||
return client.get().then(function () {
|
||||
expect.fail('promise should have been rejected');
|
||||
}, function (err) {
|
||||
expect(err.message).to.match(/unable/i);
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
client.get().then(function () {
|
||||
expect.fail('promise should have been rejected');
|
||||
}, function (err) {
|
||||
expect(err.message).to.match(/unable/i);
|
||||
done();
|
||||
it('ping\'s properly', function (done) {
|
||||
directive(function (esFactory) {
|
||||
return function () {
|
||||
prom(done, function () {
|
||||
var client = esFactory({
|
||||
hosts: 'not-a-valid-es-host.es'
|
||||
});
|
||||
|
||||
return client.ping().then(function () {
|
||||
expect.fail('promise should have been rejected');
|
||||
}, function (err) {
|
||||
// this error should be "NoConnections", but in some browsers it will be a Timeout due to testing proxy or because it's IE
|
||||
expect(err).to.be.ok();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user