Skip to content

Commit

Permalink
Merge pull request #121 from bharathkontham/master
Browse files Browse the repository at this point in the history
ElasticSearch connection error throw on initial ping is disabled
  • Loading branch information
bharathkontham authored Apr 27, 2019
2 parents 0c61705 + 2f34d0e commit d35aca2
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions lib/esConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,28 @@ ESConnector.prototype.connect = function (callback) {
} else {
self.db = new elasticsearch.Client(self.getClientConfig());
self.db.ping({
requestTimeout: 10000
requestTimeout: self.settings.requestTimeout
}, function (error) {
if (error) {
throw callback(error);
} else {
if (self.settings.mappingProperties) {
self.setupMappings()
.then(function () {
log('ESConnector.prototype.connect', 'setupMappings', 'finished');
callback && callback(null, self.db);
})
.catch(function (err) {
log('ESConnector.prototype.connect', 'setupMappings', 'failed', err);
callback && callback(null, self.db);
});
} else {
process.nextTick(function () {
callback && callback(null, self.db);
});
}
console.log('ESConnector.prototype.connect', 'ping', 'failed', error);
log('ESConnector.prototype.connect', 'ping', 'failed', error);
}
});
if (self.settings.mappingProperties) {
self.setupMappings()
.then(function () {
log('ESConnector.prototype.connect', 'setupMappings', 'finished');
callback && callback(null, self.db);
})
.catch(function (err) {
log('ESConnector.prototype.connect', 'setupMappings', 'failed', err);
callback && callback(null, self.db);
});
} else {
process.nextTick(function () {
callback && callback(null, self.db);
});
}
}
};

Expand Down Expand Up @@ -218,8 +218,9 @@ ESConnector.prototype.setupIndex = require('./setupIndex.js')({
* @returns {String} with ping result
*/
ESConnector.prototype.ping = function (cb) {
this.db.ping({
requestTimeout: 1000
var self = this;
self.db.ping({
requestTimeout: self.settings.requestTimeout
}, function (error) {
if (error) {
log('Could not ping ES.');
Expand Down

0 comments on commit d35aca2

Please sign in to comment.