NSQ Rocket 🚀
Simple framework to handle request response pattern on nsq.io
Install
To install nsq-rocket, simply use npm:
npm install nsq-rocket --save
Example
var Rocket = ; var rocket = ; rocket//Default cb for this topic if no key found//No key landing; rocket//No Routing Key
API
Rocket([opts])
Creates a new instance of Rocket.
Options are:
serviceId
loggerLevel
['silent', 'info', 'warn', 'error', 'fatal']reader
(nsqjs reader)writer
(nsqjs writer)
instance.topic(topic)
Change the current topic
instance.landing([channel, pattern, cb])
Set a new listener for NSQ
channel
, you can put your cb here if you want a random channel and no patternpattern
, you can put your cb here if you want no pattern
instance.launch(message,[pattern, cb])
Publish a new message to NSQ
pattern
, publish with a specific patterncb
, if you want listen for reply
instance.default(cb)
Set a default cb for the current topic
Events
instance.reader.on(event, data)
- discard -> message
- error -> error
- connected -> {host: host, port: port}
- closed -> {host: host, port: port}
- replier_error -> error
instance.writer.on(event, data)
- ready
- closed
- error -> error