npm.io
2.0.1 • Published 9 years ago

pm2-pubsub

Licence
MIT
Version
2.0.1
Deps
3
Vulns
0
Weekly
0
Stars
8

pm2-pubsub

Based on WS (UWS compatible)

Usage

Server:

require('pm2-pubsub')({ server : true })

Client:

PUB/SUB

var bus = require('pm2-pubsub')('app-name');

bus.subscribe('channel1', (message) => {
  console.log('message:', message)
})

bus.publish('channel1', { some : 'data' });
RPC

Service #1:

var bus = require('pm2-pubsub')('app-name');

bus.expose('myfunction', function(data, done) {
  // some processing
  return done({ success : true, my : 'data' });
});

Consumer #1:

var bus = require('pm2-pubsub')('app-name');

bus.call('testfunction', { some : 'data'}, function(data) {
   // data = result
});

License

MIT