/mainland

Simple message queue and distribution

Primary LanguageJavaScript

Mainland

Simple message queue and distribution

Version 0.0.3

Build Status

Mainland in a message bus that lets you reliably distribute messages between different parts of your app.

API

All methods take a callback that is called with err and result. The signatures below use done to identify the callback.

### reset(done)

Delete everything

### quit(done)

Quit everything

### purge(topic, done)

Delete all unprocessed messages from a topic

### send(topic, data, done)
api.send('my-topic', {foo: 'bar'}, next);

Add a message data to the topic queue

### take(topic, done)
var done = function(err, data){};

Takes one (if any) message off the topic queue

### listen(topic, handler)
var handler = function(err, data){};

Watches the end of the topic queue and calls handler with the next available message.

Multiple listeners on the same topic will compete for messages.

If you want to distribute the same message to multiple handlers, use #router

### router(routes)

Fans out one topic to multiple topics

Router is like

{'source-topic':['target-1','target-2'], ...}

Release History

  • 28/01/2014 0.0.1 Initial release
  • 03/11/2014 0.0.3 Redux

License

Copyright (c) 2014 Simon Swain Licensed under the MIT license.