This module uses redis as the pub/sub messaging component for palmetto flow applications
var io = require('@akennedy/palmetto-redis')({
endpoint: 'http://localhost:6379',
app: '<appname>'
})
io.on('foobar', function (msg) {
console.log(msg)
})
io.emit('send', msg)
var uuid = uuid.v4()
io.on(uuid, function (event) {
console.log(event.object)
})
io.emit('send', {
to: 'widget.all.request',
from: uuid,
subject: 'widget',
verb: 'all',
type: 'request',
object: {}
})
io.on('widget.all.request', function (event) {
// do work
var results = ...
io.emit('send', {
to: event.from,
subject: 'widget',
verb: 'all',
type: 'response',
object: results
})
})
The service listens to the widget.all.request
svc then uses the from
node to publish the response to.