Open pulkitsinghal opened 9 years ago
connectors emit a connected
event once the connecter has finished initialising. Are connectors supposed to queue up their queries somehow until the connected event has been emitted?
As a workaround in our application, we have a boot script like this which ensures that queries are not made against the connector until it is truly ready:
'use strict';
var logger = require('../modules/fc/logger');
module.exports = function (app, cb) {
logger.debug('Boot waiting for ElasticSearch initialization...');
// As soon as the datasource has been connected, move on.
app.dataSources.elasticsearch.once('connected', function () {
logger.debug('ElasticSearch connected, boot continuing');
cb();
});
};
Any pointers to code would be appreciated.
I thought I had already accomplished the right flow via these lines of code:
But apparently not.