ØMQ bindings for node.js.
$ npm install zmq-prebuilt
We rely on prebuild
. Prepare to be amazed at the wonders of binaries.
To set up zmq-prebuilt
for development, clone and fork this repository. If you are running on Linux
or OS X, you will need to have automake
, autoconf
, and libtools
. These can be installed using brew
.
$ ./build_libzmq.sh
$ npm install
You can run then run the test suite.
$ npm test
Or run some of the example applications.
$ node examples/subber.js
- OS X/Darwin 64-bit
- Linux 64-bit
- Windows (we'll get this one up soon, we're so close.)
Everywhere you used require(zmq)
in your code base before, replace it with zmq-prebuilt
.
// producer.js
var zmq = require('zmq-prebuilt')
, sock = zmq.socket('push');
sock.bindSync('tcp://127.0.0.1:3000');
console.log('Producer bound to port 3000');
setInterval(function(){
console.log('sending work');
sock.send('some work');
}, 500);
// worker.js
var zmq = require('zmq-prebuilt')
, sock = zmq.socket('pull');
sock.connect('tcp://127.0.0.1:3000');
console.log('Worker connected to port 3000');
sock.on('message', function(msg){
console.log('work: %s', msg.toString());
});
// pubber.js
var zmq = require('zmq-prebuilt')
, sock = zmq.socket('pub');
sock.bindSync('tcp://127.0.0.1:3000');
console.log('Publisher bound to port 3000');
setInterval(function(){
console.log('sending a multipart message envelope');
sock.send(['kitty cats', 'meow!']);
}, 500);
// subber.js
var zmq = require('zmq-prebuilt')
, sock = zmq.socket('sub');
sock.connect('tcp://127.0.0.1:3000');
sock.subscribe('kitty cats');
console.log('Subscriber connected to port 3000');
sock.on('message', function(topic, message) {
console.log('received a message related to:', topic, 'containing message:', message);
});
After an npm
release, go through the following to create the actual prebuilds:
docker build -t zmqprebuilt .
docker run -it zmqprebuilt prebuild --all -u $GITHUB_TOKEN
From a Mac:
npm install
npm install -g prebuild
prebuild --all -u $GITHUB_TOKEN
TODO