GithubHelp home page GithubHelp logo

lovmoen / zeromq.node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from justintulloss/zeromq.node

0.0 2.0 0.0 3.63 MB

Node.js bindings to the zeromq library

License: MIT License

C++ 33.06% Python 1.89% JavaScript 51.00% CSS 0.90% C 13.15%

zeromq.node's Introduction

Build Status

node-zeromq

ØMQ bindings for node.js.

Installation

First make sure ZeroMQ is installed. This module is compatible with ZeroMQ versions 2, 3 and 4. The installation process varies by platform, but headers are mandatory. Most Linux distributions provide these headers with -devel packages like zeromq-devel or zeromq3-devel. Homebrew for OS X provides versions 4 and 3 with packages zeromq and zeromq3, respectively. A Chris Lea PPA is available for Debian-like users who want a version newer than currently provided by their distribution. Windows is supported but not actively maintained.

Note: For zap support with versions >=4 you need to have libzmq built and linked against libsodium. Check the Travis configuration for a list of what is tested and therefore known to work.

With ZeroMQ headers installed, you can install and use this module:

$ npm install zmq

Example

producer.js:

var zmq = require('zmq')
  , 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')
  , 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());
});

Running tests

Install dev deps:

 $ npm install

Build:

 $ make

Test:

 $ make test

Running benchmarks

Benchmarks are available in the perf directory, and have been implemented according to the zmq documentation: How to run performance tests

In the following examples, the arguments are respectively:

  • the host to connect to/bind on
  • message size (in bytes)
  • message count

You can run a latency benchmark by running these two commands in two separate shells:

node ./local_lat.js tcp://127.0.0.1:5555 1 100000
node ./remote_lat.js tcp://127.0.0.1:5555 1 100000

And you can run throughput tests by running these two commands in two separate shells:

node ./local_thr.js tcp://127.0.0.1:5555 1 100000
node ./remote_thr.js tcp://127.0.0.1:5555 1 100000

zeromq.node's People

Contributors

aaudis avatar alexeykupershtokh avatar bluebery avatar coreyjewett avatar f34rdotcom avatar freehaha avatar jeremybarnes avatar joshrtay avatar justintulloss avatar kkoopa avatar mgc avatar mlc avatar mojodna avatar mscdex avatar msealand avatar nponeccop avatar patricklucas avatar rasky avatar rvagg avatar ryanlelek avatar soplwang avatar sshirokov avatar tcr avatar technoweenie avatar tj avatar tootallnate avatar utvara avatar wavded avatar xla avatar yoneal avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.