🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

nsq-protocol

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nsq-protocol

The NSQ protocol for node.js implemented as a stream

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

nsq-protocol

NSQ protocol for Node.js implemented as a through stream

npm install nsq-protocol

Usage

var net = require('net');
var protocol = require('nsq-protocol');

var socket = net.connect(4150);
var p = protocol();

socket.pipe(p).pipe(socket);

p.identify({
	short_id: 'maf',
	long_id: 'mafintosh',
	heartbeat_interval: 10000,
	user_agent: 'my-client/0.1'
}, function() {
	console.log('I identified!');
});

API

The following messages can be used

  • protocol.identify(options, [callback]) Send identify. See the spec for options
  • protocol.nop() Send nop message
  • protocol.sub(topic, channel, [callback]) Subscribe to a topic on a channel
  • protocol.pub(topic, data, [callback]) Publish to a topic. Data should be a buffer or string
  • protocol.mpub(topic, list_of_data, [callback]) As above but with multiple messages
  • protocol.rdy(count) Indicate you are ready to receive messages
  • protocol.fin(message_id) Finish a message (when message processing succeeds)
  • protocol.req(message_id, timeout) Re-queue a message (when message processing fails)
  • protocol.touch(message_id) Reset the timeout for an in-flight message
  • protocol.cls() Send close message
  • protocol.destroy() Destroy the stream.

The following events are emitted (excluding standard stream events)

  • protocol.on('message', message, message_id, attempts) When a message is received
  • protocol.on('heartbeat') When a heartbeat is received

License

MIT

FAQs

Package last updated on 30 Mar 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts