switch to forever-agent
This commit is contained in:
@ -104,17 +104,16 @@ Default::: `30000`
|
||||
|
||||
|
||||
|
||||
`maxSockets`:: `Number` -- Number of sockets each connection should keep to it's corresponding node. This will also be the maximum number of concurrent requests that could be made to that node. These sockets are currently kept alive using https://github.com/TBEDP/agentkeepalive[agentkeepalive].
|
||||
`maxSockets`:: `Number` -- Number of sockets each connection should keep to it's corresponding node. This will also be the maximum number of concurrent requests that could be made to that node.
|
||||
|
||||
Default::: `10`
|
||||
|
||||
|
||||
|
||||
|
||||
`maxKeepAliveTime`:: `Number, false` -- Milliseconds of inactivity before the socket is destroyed
|
||||
|
||||
Default::: `60000`
|
||||
`forever`:: `Boolean` -- Should the connections to the node be kept open forever? This behavior is recommended when you are connecting directly to Elasticsearch.
|
||||
|
||||
Default::: `true`
|
||||
|
||||
|
||||
|
||||
|
||||
@ -67,16 +67,16 @@
|
||||
"dependencies": {
|
||||
"when": "~2.6.0",
|
||||
"lodash": "~2.3.0",
|
||||
"agentkeepalive": "~0.1",
|
||||
"chalk": "~0.3.0",
|
||||
"event-stream": "~3.1.0"
|
||||
"event-stream": "~3.1.0",
|
||||
"forever-agent": "~0.5.2"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/elasticsearch/elasticsearch-js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt test",
|
||||
"test": "node scripts/generate --branch default && grunt test",
|
||||
"generate": "node scripts/generate"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@ -14,7 +14,7 @@ var handles = {
|
||||
};
|
||||
var _ = require('../utils');
|
||||
var qs = require('querystring');
|
||||
var KeepAliveAgent = require('agentkeepalive');
|
||||
var ForeverAgent = require('forever-agent');
|
||||
var ConnectionAbstract = require('../connection');
|
||||
|
||||
/**
|
||||
@ -34,17 +34,17 @@ function HttpConnector(host, config) {
|
||||
}
|
||||
|
||||
config = _.defaults(config || {}, {
|
||||
maxSockets: 10,
|
||||
maxKeepAliveRequests: 0,
|
||||
maxKeepAliveTime: 3e5 // 5 minutes
|
||||
forever: true,
|
||||
maxSockets: 10
|
||||
});
|
||||
|
||||
var KeepAliveAgent_ = this.host.protocol === 'https' ? KeepAliveAgent.HttpsAgent : KeepAliveAgent;
|
||||
var Agent = this.hand.Agent; // the class
|
||||
if (config.forever) {
|
||||
Agent = this.host.protocol === 'https' ? ForeverAgent.SSL : ForeverAgent;
|
||||
}
|
||||
|
||||
this.agent = new KeepAliveAgent_({
|
||||
maxSockets: config.maxSockets,
|
||||
maxKeepAliveRequests: config.maxKeepAliveRequests,
|
||||
maxKeepAliveTime: config.maxKeepAliveTime
|
||||
this.agent = new Agent({
|
||||
maxSockets: config.maxSockets
|
||||
});
|
||||
}
|
||||
_.inherits(HttpConnector, ConnectionAbstract);
|
||||
|
||||
Reference in New Issue
Block a user