[config] add sniffedNodesFilterPath option (#559)

This commit is contained in:
Spencer
2017-06-18 11:01:23 -04:00
committed by GitHub
parent 9d3b966f63
commit 8d9d6cb88c
2 changed files with 19 additions and 9 deletions

View File

@ -181,6 +181,11 @@ Defaults:::
Default::: If all of the hosts/host passed to the client via configuration use the same protocol then this defaults to that protocol, otherwise it defaults to `"http"`. Default::: If all of the hosts/host passed to the client via configuration use the same protocol then this defaults to that protocol, otherwise it defaults to `"http"`.
`sniffedNodesFilterPath`[[config-sniffed-filter-path]]:: `String` -- Defines the https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#common-options-response-filtering:`filter_path` used when fetching the node list from Elasticsearch.
Default::: `'nodes.*.http.publish_address,nodes.*.name,nodes.*.hostname,nodes.*.host,nodes.*.version'`
`ssl`[[config-ssl]]:: `Object` -- An object defining HTTPS/SSL configuration to use for all nodes. The properties of this mimic the options accepted by http://nodejs.org/docs/latest/api/tls.html#tls_tls_connect_port_host_options_callback[`tls.connect()`] with the exception of `rejectUnauthorized`, which defaults to `false` allowing self-signed certificates to work out-of-the-box. `ssl`[[config-ssl]]:: `Object` -- An object defining HTTPS/SSL configuration to use for all nodes. The properties of this mimic the options accepted by http://nodejs.org/docs/latest/api/tls.html#tls_tls_connect_port_host_options_callback[`tls.connect()`] with the exception of `rejectUnauthorized`, which defaults to `false` allowing self-signed certificates to work out-of-the-box.
+ +
Additional information available in <<auth-reference>>. Additional information available in <<auth-reference>>.

View File

@ -73,6 +73,18 @@ function Transport(config) {
self.sniffedNodesProtocol = findCommonProtocol(self.connectionPool.getAllHosts()) || null; self.sniffedNodesProtocol = findCommonProtocol(self.connectionPool.getAllHosts()) || null;
} }
if (config.hasOwnProperty('sniffedNodesFilterPath')) {
self.sniffedNodesFilterPath = config.sniffedNodesFilterPath;
} else {
self.sniffedNodesFilterPath = [
'nodes.*.http.publish_address',
'nodes.*.name',
'nodes.*.hostname',
'nodes.*.host',
'nodes.*.version',
].join(',');
}
if (config.sniffOnStart) { if (config.sniffOnStart) {
self.sniff(); self.sniff();
} }
@ -396,21 +408,14 @@ Transport.prototype.sniff = function (cb) {
const nodesToHostCallback = this.nodesToHostCallback; const nodesToHostCallback = this.nodesToHostCallback;
const log = this.log; const log = this.log;
const sniffedNodesProtocol = this.sniffedNodesProtocol; const sniffedNodesProtocol = this.sniffedNodesProtocol;
const sniffedNodesFilterPath = this.sniffedNodesFilterPath;
// make cb a function if it isn't // make cb a function if it isn't
cb = typeof cb === 'function' ? cb : _.noop; cb = typeof cb === 'function' ? cb : _.noop;
this.request({ this.request({
path: this.sniffEndpoint, path: this.sniffEndpoint,
query: { query: { filter_path: sniffedNodesFilterPath },
filter_path: [
'nodes.*.http.publish_address',
'nodes.*.name',
'nodes.*.hostname',
'nodes.*.host',
'nodes.*.version',
].join(','),
},
method: 'GET' method: 'GET'
}, function (err, resp, status) { }, function (err, resp, status) {
if (!err && resp && resp.nodes) { if (!err && resp && resp.nodes) {