andela-pubsub
v1.5.10
Published
a library that will house our pubsub implementation
Downloads
71
Readme
Andela Pubsub
This package houses tech team pubsub implementation.
Usage
To emit an event, use
const pubsub = require('andela-pubsub')
pubsub.emit({ data: payload, attributes: { eventType: 'NameOfEvent', ... }}, topicName)
To subscribe to an event, use
const pubsub = require('andela-pubsub')
const handlers = {
EventName: async HandlerFunction
}
pubsub.subscribe([ { topicName, subscriptionName }], handlers )
To set custom deadline timeout (time needed to process an event), use
const pubsub = require('andela-pubsub')
const handlers = {
EventName: { timeoutInSeconds: xxxx, method: async HandlerFunction }
}
pubsub.subscribe([ { topicName, subscriptionName }], handlers )