Skip to content

clayzermk1/mongodb-pubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

MongoDB backed pub/sub

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published