Distributed messaging framework
Simple distributed messaging built with ZeroMQ.
npm install gossip
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..
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
This would look like:
//// Gauges server//var gossip = require'gossip';// Nodes are the building block of gossip. You should run one node per process.// They can send and receive messages to / from a cluster of nodes.var node = 'ipc://temp-gauges';// You can subscribe to messages you are interested in.// Any node can check your temperature by sending you a `check-temp` message. Yay!nodeon'check-temp'var gauge = gaugesmessagedatagauge;// read the temperaturevar temp = gaugereadTemp;// send a response backvar response =temp: temptime: Datenow;nodereplymessage response;;//// Monitor server//var gossip = require'gossip';var node = 'ipc://temp-monitor';// Join the monitor to the gauges. This will allows the node to send messages to any nodes that are known// by the node you are connecting to.nodejoin'ipc://temp-gauges';setInterval// check temperaturenodesend'check-temp' gauge: 'main'if responsedatatemp > 600// sound the alarm100;;