Moleculer <-> Hemera sidecar/gateway.
- call Hemera service from Moleculer service
- call Moleculer service from Hemera service
- emit Moleculer event from Hemera service
- broadcast Moleculer event from Hemera service
npm install moleculer-sidecar-hemera
Call a Hemera service
broker.call("hemera.act", { topic: "math", cmd: "add", a: 5, b: 3 })
.then(res => broker.logger.info("Result: ", res))
.catch(err => broker.logger.error(err));
Call a Moleculer service
hemera.act({
topic: "moleculer",
cmd: "call",
action: "greeter.welcome",
params: {
name: "John"
}
}).then(msg => hemera.log.info("Result: ", msg.data))
.catch(err => hemera.log.error(err));
Emit a Moleculer event
hemera.act({
topic: "moleculer",
cmd: "emit",
event: "user.created",
payload: {
id: 5,
name: "John"
}
// groups: []
}).catch(err => hemera.log.error(err));
Broadcast a Moleculer event
hemera.act({
topic: "moleculer",
cmd: "broadcast",
event: "user.created",
payload: {
id: 5,
name: "John"
}
// groups: []
}).catch(err => hemera.log.error(err));
Property | Type | Default | Description |
---|---|---|---|
natsOptions |
Object |
undefined |
NATS connect options for Hemera. |
hemeraOptions |
Object |
{} |
Hemera constructor options. |
$ npm test
In development with watching
$ npm run ci
Please send pull requests improving the usage and fixing bugs, improving documentation and providing better examples, or providing some testing, because these things are important.
The project is available under the MIT license.
Copyright (c) 2018 MoleculerJS