0.0.1 • Published 10 years ago

mongodb-pubsub v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

mongodb-pubsub

Build Status

Turns MongoDB into a pub/sub message broker.

Based on this enligtening blog post.

Install

npm install mongodb-pubsub

Example

var PubSub = require('mongodb-pubsub')
  , util = require('util');

// create a new instance
var ps = new PubSub();

// open the connection to the broker
ps.open(function (err) {
  if (err !== null) throw err;

  // you can use the local events or the callbacks
  ps.on('subscribe', function () {
    ps.publish('foo', 'bar', 'baz'); // takes multiple arguments
  });

  // subscribe to a channel
  ps.subscribe('foo', function () {
    console.log('got a foo!', util.inspect(arguments));
    ps.close(); // tidy up
  })
});

API Documentation

Source code documentation can be generated by running npm install && npm run-script doc. Generated documentation will be in the ./doc directory.

Testing

npm install && npm test

License

Copyright 2014 Clay Walker
MIT License