Event Bus for Hydra Micro-service
Provides the Event Bus for Hydra-based Micro-service.
Installation
$ npm install --save hydra-event-bus-plugin
Setup
Setup .use(new EventBusPlugin())
in your service to register the plugin, then you can use hydra.eventBus
to access the plugin
'use strict'; const version = version;const hydra = ;let config = ; const HydraLogger = HydraLogger;const EventBusPlugin = ;hydra;hydra; const Promise = ; config ;
Try it out
Open your terminal, clone and start hydra-event-bus-service
$ git clone https://github.com/khoinguyen/hydra-event-bus-service.git
$ cd hydra-event-bus-service
$ cp config/sample-config.json config/config.json
$ npm install
$ npm start
In another terminal, start your service.
API Reference
.on(pattern: string, callback: function)
to register the callback to the pattern. The callback receiveeventName
,payload
andUMF message
.off(pattern: string, callback: function)
to un-register the pattern. Please note, the pattern must be exactly as the pattern registered..emit(eventName: string, payload: object)
to emit the event to Event Bus.