[config] add sniffedNodesFilterPath option (#559)
(cherry picked from commit 8d9d6cb88c)
This commit is contained in:
@ -73,6 +73,18 @@ function Transport(config) {
|
||||
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) {
|
||||
self.sniff();
|
||||
}
|
||||
@ -396,21 +408,14 @@ Transport.prototype.sniff = function (cb) {
|
||||
var nodesToHostCallback = this.nodesToHostCallback;
|
||||
var log = this.log;
|
||||
var sniffedNodesProtocol = this.sniffedNodesProtocol;
|
||||
var sniffedNodesFilterPath = this.sniffedNodesFilterPath;
|
||||
|
||||
// make cb a function if it isn't
|
||||
cb = typeof cb === 'function' ? cb : _.noop;
|
||||
|
||||
this.request({
|
||||
path: this.sniffEndpoint,
|
||||
query: {
|
||||
filter_path: [
|
||||
'nodes.*.http.publish_address',
|
||||
'nodes.*.name',
|
||||
'nodes.*.hostname',
|
||||
'nodes.*.host',
|
||||
'nodes.*.version',
|
||||
].join(','),
|
||||
},
|
||||
query: { filter_path: sniffedNodesFilterPath },
|
||||
method: 'GET'
|
||||
}, function (err, resp, status) {
|
||||
if (!err && resp && resp.nodes) {
|
||||
|
||||
Reference in New Issue
Block a user