particle-iot/zeromq.js

Name: zeromq.js

Owner: Particle

Description: :zap: Node.js bindings to the ØMQ library

Forked from: zeromq/zeromq.js

Created: 2017-12-28 15:32:59.0

Updated: 2017-12-28 15:33:01.0

Pushed: 2018-03-12 19:19:58.0

Homepage: http://zeromq.github.io/zeromq.js/

Size: 2811

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

zeromq

codecov Greenkeeper badge Build Status Build status Build Status Build status

Users | From Source | Contributors and Development | Maintainers

zeromq: Your ready to use, prebuilt ØMQ bindings for Node.js.

ØMQ provides handy functionality when working with sockets. Yet, installing dependencies on your operating system or building ØMQ from source can lead to developer frustration.

zeromq simplifies creating communications for a Node.js application by providing well-tested, ready to use ØMQ bindings. zeromq supports all major operating systems, including:

Use zeromq and take advantage of the elegant simplicity of binaries.

Installation - Users

We rely on prebuild.

Install zeromq with the following:

install zeromq

Now, prepare to be amazed by the wonders of binaries.

To use your system's libzmq (if it has been installed and development headers are available):

install zeromq --zmq-external
Rebuilding for Electron

If you want to use zeromq inside your Electron application it needs to be rebuild against Electron headers. We ship prebuilt binaries for Electron so you won't need to build zeromq from source.

You can rebuild zeromq manually by running:

rebuild zeromq --runtime=electron --target=1.4.5

Where target is your desired Electron version. This will download the correct binary for usage in Electron.

For packaging your Electron application we recommend using electron-builder which handles rebuilding automatically. Enable the npmSkipBuildFromSource option to make use of the prebuilt binaries. For a real world example take a look at nteract.

Installation - From Source

If you are working on a Linux 32-bit system or want to install a developement version, you have to build zeromq from source.

Prerequisites

Linux

Use your distribution's package manager to install.

macOS

Windows

Installation

Now you can install zeromq with the following:

install zeromq
Installation - Contributors and Development

To set up zeromq for development, fork this repository and clone your fork to your system.

Make sure you have the required dependencies for building zeromq from source installed.

Install a development version of zeromq with the following:

install
Testing

Run the test suite using:

test
Running an example application

Several example applications are found in the examples directory. Use node to run an example. To run the 'subber' application, enter the following:

 examples/subber.js
Examples using zeromq
Push/Pull

This example demonstrates how a producer pushes information onto a socket and how a worker pulls information from the socket.

producer.js

roducer.js
zmq = require('zeromq')
sock = zmq.socket('push');

.bindSync('tcp://127.0.0.1:3000');
ole.log('Producer bound to port 3000');

nterval(function(){
nsole.log('sending work');
ck.send('some work');
00);

worker.js

orker.js
zmq = require('zeromq')
sock = zmq.socket('pull');

.connect('tcp://127.0.0.1:3000');
ole.log('Worker connected to port 3000');

.on('message', function(msg){
nsole.log('work: %s', msg.toString());

Pub/Sub

This example demonstrates using zeromq in a classic Pub/Sub, Publisher/Subscriber, application.

Publisher: pubber.js

ubber.js
zmq = require('zeromq')
sock = zmq.socket('pub');

.bindSync('tcp://127.0.0.1:3000');
ole.log('Publisher bound to port 3000');

nterval(function(){
nsole.log('sending a multipart message envelope');
ck.send(['kitty cats', 'meow!']);
00);

Subscriber: subber.js

ubber.js
zmq = require('zeromq')
sock = zmq.socket('sub');

.connect('tcp://127.0.0.1:3000');
.subscribe('kitty cats');
ole.log('Subscriber connected to port 3000');

.on('message', function(topic, message) {
nsole.log('received a message related to:', topic, 'containing message:', message);

For maintainers: Creating a release

When making a release, do the following:

version minor && git push && git push --tags

Then, wait for the prebuilds to get uploaded for each OS. After the prebuilds are uploaded, run the following to publish the release:

publish
Background

This codebase largely came from the npm module zmq and was, at one point, named nteract/zmq-prebuilt. It started as a community run fork of zmq that fixed up the build process and automated prebuilt binaries. In the process of setting up a way to do statically compiled binaries of zeromq for node, zmq-static was created. Eventually zmq-prebuilt was able to do the job of zmq-static and it was deprecated. Once zmq-prebuilt was shipping for a while, allowed building from source, and suggesting people use it for electron + node.js, the repository moved to the zeromq org and it became official.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.