co wrapper for mongomq package.
const MongoMQ = require('co-mongomq');
const queue = new MongoMQ();
yield queue.start();
// monitoring process
queue.on('test', function*(error, message) {
// co context here, so you can yield :)
console.log(message);
});
// emitting process
yield queue.emit('test', { my: 'message' });
Please refer to the documentation of MongoMQ.
require('co-mongomq')
directly returns theMongoMQ
property (no need to use.MongoMQ
).new MongoMQ()
options do not supportautoStart
. Start manually..emit()
requires ayield
and returns as soon as the message was added to the database (or failed)..addListener()
(aka.on()
) takes a generator as handler which is run in a co context so you can useyield
..addListener()
(aka.on()
) does not have the third argument namednext
. It will be called implicitly unless the generator returns withfalse
(and onlyfalse
- not something falsey)..broadcast()
requires ayield
but does always return immediately since MongoMQ does not support a callback here. It's still asynchronous for forward compatibility.
$ npm install co-mongomq
Node 0.11+, run with --harmony
flag.
MIT