nsq-protocol
NSQ protocol for Node.js implemented as a through stream
npm install nsq-protocol
Usage
var net = ;var protocol = ;var socket = net;var p = ;socket;p;
API
The following messages can be used
protocol.identify(options, [callback])
Send identify. See the spec for optionsprotocol.nop()
Send nop messageprotocol.sub(topic, channel, [callback])
Subscribe to a topic on a channelprotocol.pub(topic, data, [callback])
Publish to a topic. Data should be a buffer or stringprotocol.mpub(topic, list_of_data, [callback])
As above but with multiple messagesprotocol.rdy(count)
Indicate you are ready to receive messagesprotocol.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 messageprotocol.cls()
Send close messageprotocol.destroy()
Destroy the stream.
The following events are emitted (excluding standard stream events)
protocol.on('message', message, message_id, attempts)
When a message is receivedprotocol.on('heartbeat')
When a heartbeat is received
License
MIT