Gossip
Simple distributed messaging built with ZeroMQ.
Install
npm install gossip
Note:
Make sure you have you have ZeroMQ v3.2.3+ installed.
If you are using OS X you can use brew
to install ZeroMQ:
brew install zeromq
For Windows / UNIX check the instructions here..
Quick Start
Suppose you wanted to monitor the temperature of a bunch of remote gauges so things don't blow up.
A typical setup for this would be to run a monitor Node
and a gauge Node
.
This would look like:
var gossip = require('gossip');
var node = new gossip.Node('ipc://temp-gauges');
node.on('check-temp', function (message, reply) {
var gauge = gauges[message.data.gauge];
var temp = gauge.readTemp();
var response = {
temp: temp,
time: Date.now()
};
node.reply(message, response);
});
var gossip = require('gossip');
var node = new gossip.Node('ipc://temp-monitor');
node.join('ipc://temp-gauges');
setInterval(function () {
node.send('check-temp', { gauge: 'main' }, function (err, response) {
if (response.data.temp > 600) {
}
}, 100);
});
API Docs
See here.