nats-hemera
Advanced tools
Comparing version 3.1.5 to 3.1.6
@@ -1,3 +0,1 @@ | ||
'use strict' | ||
/** | ||
@@ -68,2 +66,3 @@ * Copyright 2016-present, Dustin Deus (deusdustin@gmail.com) | ||
this._isReady = false | ||
this._config = config.value | ||
@@ -534,2 +533,8 @@ this._router = Bloomrun(this._config.bloomrun) | ||
ready(cb) { | ||
if (this._isReady) { | ||
throw new Errors.HemeraError('Hemera is already bootstraped') | ||
} | ||
this._isReady = true | ||
this._transport.driver.on('error', err => { | ||
@@ -567,17 +572,18 @@ this.log.error(err, Constants.NATS_TRANSPORT_ERROR) | ||
const bootstrapCb = (err, cb) => { | ||
if (err) { | ||
this.log.error(err) | ||
} | ||
if (_.isFunction(cb)) { | ||
cb(err) | ||
} | ||
} | ||
if (this._transport.driver.connected) { | ||
this.log.info(Constants.NATS_TRANSPORT_CONNECTED) | ||
this.bootstrap(err => { | ||
if (_.isFunction(cb)) { | ||
cb(err) | ||
} | ||
}) | ||
this.bootstrap(err => bootstrapCb(err, cb)) | ||
} else { | ||
this._transport.driver.on('connect', () => { | ||
this.log.info(Constants.NATS_TRANSPORT_CONNECTED) | ||
this.bootstrap(err => { | ||
if (_.isFunction(cb)) { | ||
cb(err) | ||
} | ||
}) | ||
this.bootstrap(err => bootstrapCb(err, cb)) | ||
}) | ||
@@ -584,0 +590,0 @@ } |
{ | ||
"name": "nats-hemera", | ||
"author": "Dustin Deus (https://github.com/StarpTech)", | ||
"version": "3.1.5", | ||
"version": "3.1.6", | ||
"main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://hemerajs.github.io/hemera/", |
71028
2819