Hemera package
This is the core package of hemera. For more details see Hemera
The core package of hemera
This is the core package of hemera. For more details see Hemera
Further changelogs are tracked in Github releases
exit
event in graceful shutdown routine.Update bloomrun to 4.0.0
Update tinysonic
to 1.3.0 to fix parsing issues in short json syntax e.g act('a:22de')
, àct('a: null')
The bloomrun
config lookupBeforeAdd
is set to false
by default. This allows to add pattern without to respecting the pattern matching order.
It has no impact on the pattern matching rules.
instanceof
comparison.hemera.createError
is registered in errio..use()
inside pluginsact
and add
and throw error when pattern is undefinedact
act
Functional style in extensions and life-cycle-events. In future we can provide a more consistent and encapsulated interface.
Old:
hemera.ext('onServerPreRequest', function (req, res, next) {
const ctx = this
next()
})
hemera.ext('onClose', (done) => {
const ctx = this
done()
})
New:
hemera.ext('onServerPreRequest', function (ctx, req, res, next) {
next()
})
hemera.ext('onClose', (ctx, done) => {
done()
})
Old:
hemera.ext('clientPostRequest', function () {
const ctx = this
})
New:
hemera.ext('onServerPreRequest', function (ctx) {
next()
})
Lerna issues
Much better Typescript support
Implement a new interface to create a pipeline for encoding and decoding the messages. hemera-msgpack
, hemera-snappy
and hemera-avro
was updated.
New:
// Replace the default decoder/encoder
hemera.decoder.reset(decode)
hemera.encoder.reset(decode)
// Remove all steps
hemera.decoder.reset()
// Move the pipeline at the first place e.g for compressing algorithms
hemera.decoder.first(uncompress)
// Add a new pipeline step
hemera.decoder.add(function() {
return { value: <payload>, error: <error> }
})
The close
method is async and accept a callback. Before the close callback is called all registered subscriptions are unsubscribed from NATS as well as all registered pattern. Plugins which have been registered an onClose
extension can clean up. Every IO will be flushed to NATS before the close callback is called.
close
method is async and accept a callbackonClose
extension you can do:
Old:hemera.close()
New:
hemera.close((err) => ...)
onClose
handler otherwise the server won't gracefully shutdown before the next test can start.Old:
hemera.close()
New:
hemera.close(done)
remove(<topic>)
all pattern which belongs to it will be deleted.request.timstamp
and request.duration
already present in trace
)debug
PATTERN_ALREADY_IN_USE
Errorhemera.fatal
signal-exit
package and implement a much simpler signal handler to gracefully exit hemera.trace$.method
to errorDetails.queue$
property in add
pattern.generators
options was removed.act
and the last one does not provide a callback. tag
property to tagging hemera instances. Used in hemera-zipkin
to indicate the server instance.hemera.ext(req, resp, next, prevValue, index)
onClose
extension point to gracefully shutdown services like hemera-mongo-store and hemera-webstandard
package to lint.hemera-plugin
dependencies
property from all hemera packagessafe-buffer
in hemera-avro packageHemera is no longer responsible to handle plugin dependencies.
childLogger
for plugins: It uses internally the child bindings of Pino therefore only possible with default logger Pino.Example:
[2017-05-21T12:11:05.818Z] INFO (hemera-starptech/17328 on starptech):
plugin: "hemera-web"
inbound: {
"id": "33badc7834f541faaf3f4d79a8958715",
"duration": 0.005121,
"pattern": "a:1,b:2,cmd:add,topic:math"
}
close
event: Is fired before the transport connection is closed. load: {
shouldCrash: true, // Should gracefully exit the process to recover from memory leaks or load, crashOnFatal must be enabled
}
a.*.b
, a.>
.[object Object]
Manage plugin dependencies. The dependencies
attribute is used to identify the dependencies of a plugin. When the plugin could not be resolved a warning appears and an error is thrown. Does not provide version dependency which should be implemented using npm peer dependencies.
exports.plugin = function myPlugin (options) {
var hemera = this
hemera.add({
topic: 'math',
cmd: 'add'
}, (req, cb) => {
cb(null, req.a + req.b)
})
}
exports.options = {}
exports.attributes = {
dependencies: ['hemera-joi'],
pkg: require('./package.json')
}
Error Message
Plugin `myPlugin` requires `hemera-foo` as dependency. Please install with 'npm install --save hemera-foo'
Throw only on NATS connection issues. Complete NATS connection error codes. Ensure that we cover all possible cases.
Throw only on NATS connection issues. Authorization and Protocol issues are logged but don't lead to a process termination.
hemera 1.2.0 is focused on error handling, plugin dependencies
You get the exact error you have sent. Errors are wrapped only for framework errors (Parsing errors, Plugin registration errors, Timeout errors) or logging.
Old:
hemera.add({
topic: 'email',
cmd: 'send'
}, (resp, cb) => {
cb(new Error('Uups'))
})
hemera.act({
topic: 'email',
cmd: 'send',
email: 'foobar@gmail.com',
msg: 'Hi!'
}, (err, resp) => {
expect(err).to.be.exists()
expect(err.name).to.be.equals('BusinessError')
expect(err.message).to.be.equals('Business Error')
expect(err.cause.name).to.be.equals('Error')
expect(err.cause.message).to.be.equals('Uups')
hemera.close()
done()
})
New:
hemera.add({
topic: 'email',
cmd: 'send'
}, (resp, cb) => {
cb(new Error('Uups'))
})
hemera.act({
topic: 'email',
cmd: 'send',
email: 'foobar@gmail.com',
msg: 'Hi!'
}, (err, resp) => {
expect(err).to.be.exists()
expect(err.name).to.be.equals('Error')
expect(err.message).to.be.equals('Uups')
hemera.close()
done()
})
All logs are wrapped with the correct Hemera error subclass BusinessError, FatalError ...
Plugin dependencies are declared with peerDependencies instead with dependencies
property in the plugin.
Old:
exports.attributes = {
dependencies: ['hemera-joi']
pkg: require('./package.json')
}
New:
"peerDependencies": {
"hemera-joi": "^1.0.4",
"nats-hemera": "1.x || 2.x"
}