nats-hemera
Advanced tools
Comparing version
@@ -533,3 +533,3 @@ /** | ||
if (this._isReady) { | ||
throw new Errors.HemeraError('Hemera is already bootstraped') | ||
throw new Errors.HemeraError('Hemera was already bootstraped') | ||
} | ||
@@ -571,20 +571,38 @@ | ||
const bootstrapCb = (err, cb) => { | ||
if (err) { | ||
this.log.error(err) | ||
const ready = cb => { | ||
if (this._transport.driver.connected) { | ||
this.log.info(Constants.NATS_TRANSPORT_CONNECTED) | ||
this.bootstrap(cb) | ||
} else { | ||
this._transport.driver.on('connect', () => { | ||
this.log.info(Constants.NATS_TRANSPORT_CONNECTED) | ||
this.bootstrap(cb) | ||
}) | ||
} | ||
if (_.isFunction(cb)) { | ||
cb(err) | ||
} | ||
} | ||
if (this._transport.driver.connected) { | ||
this.log.info(Constants.NATS_TRANSPORT_CONNECTED) | ||
this.bootstrap(err => bootstrapCb(err, cb)) | ||
} else { | ||
this._transport.driver.on('connect', () => { | ||
this.log.info(Constants.NATS_TRANSPORT_CONNECTED) | ||
this.bootstrap(err => bootstrapCb(err, cb)) | ||
// callback style | ||
if (_.isFunction(cb)) { | ||
ready(err => { | ||
if (err) { | ||
this.log.error(err) | ||
cb(err) | ||
return | ||
} | ||
cb() | ||
}) | ||
return | ||
} | ||
// promise style | ||
return new Promise((resolve, reject) => { | ||
ready(err => { | ||
if (err) { | ||
this.log.error(err) | ||
reject(err) | ||
return | ||
} | ||
resolve() | ||
}) | ||
}) | ||
} | ||
@@ -591,0 +609,0 @@ |
{ | ||
"name": "nats-hemera", | ||
"author": "Dustin Deus (https://github.com/StarpTech)", | ||
"version": "3.1.9", | ||
"version": "3.2.0", | ||
"main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://hemerajs.github.io/hemera/", |
2836
0.6%71531
-1.8%