Skip to content
This repository has been archived by the owner on Feb 22, 2019. It is now read-only.

fluidsonic/co-mongomq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

co-mongomq

co wrapper for mongomq package.

Quickstart

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' });

Usage

Please refer to the documentation of MongoMQ.

Differences to MongoMQ

  • require('co-mongomq') directly returns the MongoMQ property (no need to use .MongoMQ).
  • new MongoMQ() options do not support autoStart. Start manually.
  • .emit() requires a yield 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 use yield.
  • .addListener() (aka .on()) does not have the third argument named next. It will be called implicitly unless the generator returns with false (and only false - not something falsey).
  • .broadcast() requires a yield but does always return immediately since MongoMQ does not support a callback here. It's still asynchronous for forward compatibility.

Installation

$ npm install co-mongomq

Requirements

Node 0.11+, run with --harmony flag.

License

MIT

About

co wrapper for mongomq package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published