Skip to content

Commit d35aca2

Browse files
Merge pull request #121 from bharathkontham/master
ElasticSearch connection error throw on initial ping is disabled
2 parents 0c61705 + 2f34d0e commit d35aca2

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

lib/esConnector.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,28 @@ ESConnector.prototype.connect = function (callback) {
121121
} else {
122122
self.db = new elasticsearch.Client(self.getClientConfig());
123123
self.db.ping({
124-
requestTimeout: 10000
124+
requestTimeout: self.settings.requestTimeout
125125
}, function (error) {
126126
if (error) {
127-
throw callback(error);
128-
} else {
129-
if (self.settings.mappingProperties) {
130-
self.setupMappings()
131-
.then(function () {
132-
log('ESConnector.prototype.connect', 'setupMappings', 'finished');
133-
callback && callback(null, self.db);
134-
})
135-
.catch(function (err) {
136-
log('ESConnector.prototype.connect', 'setupMappings', 'failed', err);
137-
callback && callback(null, self.db);
138-
});
139-
} else {
140-
process.nextTick(function () {
141-
callback && callback(null, self.db);
142-
});
143-
}
127+
console.log('ESConnector.prototype.connect', 'ping', 'failed', error);
128+
log('ESConnector.prototype.connect', 'ping', 'failed', error);
144129
}
145130
});
131+
if (self.settings.mappingProperties) {
132+
self.setupMappings()
133+
.then(function () {
134+
log('ESConnector.prototype.connect', 'setupMappings', 'finished');
135+
callback && callback(null, self.db);
136+
})
137+
.catch(function (err) {
138+
log('ESConnector.prototype.connect', 'setupMappings', 'failed', err);
139+
callback && callback(null, self.db);
140+
});
141+
} else {
142+
process.nextTick(function () {
143+
callback && callback(null, self.db);
144+
});
145+
}
146146
}
147147
};
148148

@@ -218,8 +218,9 @@ ESConnector.prototype.setupIndex = require('./setupIndex.js')({
218218
* @returns {String} with ping result
219219
*/
220220
ESConnector.prototype.ping = function (cb) {
221-
this.db.ping({
222-
requestTimeout: 1000
221+
var self = this;
222+
self.db.ping({
223+
requestTimeout: self.settings.requestTimeout
223224
}, function (error) {
224225
if (error) {
225226
log('Could not ping ES.');

0 commit comments

Comments
 (0)