npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zmq-3.0

v2.0.3

Published

Bindings for node.js to zeromq. Forked from Datasift to support 0MQ3.1

Downloads

12

Readme

This library gives you bindings to ØMQ from node.js. This is not terribly well tested, but there is at least one company successfully using these bindings in production. Bug reports welcome.

To Install

First, get [ØMQ 3.0], Homebrew on Mac will get you what you need. Debian/Ubuntu users may also need to install the libev-dev package.

Then use npm to install zeromq.node:

$ npm install zmq

npm will yell at you if you don't have node 0.3.0, as that is required.

API

The API contains elements of the ØMQ API. You should refer to it for in depth detail of the expected behaviors of the system. These methods will never return error codes, but may throw an exception if any of the errors described in the ØMQ documentation occur.

First, include the module:

zmq = require('zmq');

After that, you can create sockets with:

socket = zmq.createSocket('req');

Using ØMQ sockets

A socket is where the action happens. You can send and receive things and it is oh such fun.

Constructor - function(type)

  • type - A string describing the type of socket. You can read about the different socket types here. The name you use here matches the names of the ZMQ_* constants, sans the ZMQ_ prefix.

Methods

  • connect(address) - Connect to another socket. address should be a string as described in the ØMQ API docs. This method is not asynchronous because it is non-blocking. ØMQ will use the provided address when it's necessary and will not block here.

  • bind(address, callback) - Bind to a socket to wait for incoming data. address should be a string as described in the ØMQ API docs. callback will be called when binding is complete and takes one argument, which may be an Error, or simply undefined if everything's peachy.

  • send(message, ...) - message is a string to send across the wire. The message is not sent immediately, but there is no callback indicating when it has been transmitted. Have your server ack or something if you care that much.

    The message must be a Buffer object or a string. It is assumed that strings should be transmitted as UTF-8. If you provide more than one argument to send, then a multipart ØMQ message will be sent.

  • close() - Closes the socket

Socket Options

To set a socket option on a socket, use socket[property]. For example,

socket['identity'] = "mainLoop";

The following properties are available (the ZMQ_XXX constant describes the name in the ZeroMQ documentation available at ØMQ setsockopt API):

  • ioThreadAffinity - set affinity for IO thread (integer, ZMQ_AFFINITY);
  • backlog - set connection backlog for listening sockets (integer, ZMQ_BACKLOG);
  • identity - set the socket identity (name) (string, ZMQ_IDENTITY);
  • lingerPeriod - set the linger period in milliseconds (integer, -1 = unlimited, ZMQ_LINGER);
  • receiveBufferSize - set the kernel receive buffer size (integer, 0 = OS default, ZMQ_RCVBUF);
  • sendBufferSize - set the kernel receive buffer size (integer, 0 = OS default, ZMQ_RCVBUF);

The following apply to message buffering and reconnection:

  • reconnectionInterval - set the time to wait between reconnection attempts in milliseconds (ZeroMQ attempts to reconnect broken connection automatically behind the scenes) (integer, ZMQ_RECONNECT_IVL)
  • highWaterMark - set high water mark (in number of outstanding messages) before buffered messages start being dropped or swapped to disk (integer, zero = unlimited, ZMQ_HWM);
  • diskOffloadSize - set the amount of disk swap space in bytes for buffering messages in case of disconnection (integer, ZMQ_SWAP)

The following options are applicable to multicast:

  • multicastLoop - set whether multicast can go over loopback or not (boolean, ZMQ_MCAST_LOOP);
  • multicastDataRate - set maximum multicast transmission rate in kbits per second (integer, ZMQ_RATE);
  • multicastRecovery - set maximum multicast recovery interval in seconds (integer, ZMQ_RECOVERY_IVL)

The following properties are exposed but not normally used by client code (they are used internally by the library):

  • _fd - File descriptor (integer, ZMQ_FD);
  • _ioevents - Event loop used internally (ZMQ_EVENTS);
  • _receiveMore - Message has more parts (boolean, ZMQ_RCVMORE);
  • _subscribe - Subscribe to a channel (see subscribe() method) (string, ZMQ_SUBSCRIBE);
  • _unsubscribe - Unsubscribe to a channel (see unsubscribe() method) (string, ZMQ_UNSUBSCRIBE);

Events

  • message - A message was received. The arguments are the parts of the message. So, for example, if you have an xrep socket with plain req sockets on the other end, you can do something like:

    socket.on('message', function(envelope, blank, data) {
      socket.send(envelope, blank, compute_reply_for(data));
    });
  • error - There was some error. The only argument is an Error object explaining what the error was.

To Build

 $ node-waf configure build

Testing

Tests are pretty incomplete right now, but to run what's there:

$ npm install vows
$ vows

Licensing

Licensed under the very permissive MIT License.