upring-pubsub
v0.3.0
Published
PubSub system built on top of upring
Downloads
9
Readme
UpRingPubSub
PubSub system built on top of an UpRing consistent hashring.
You will get a pubsub system that is consistently available, so it can lose messages when the topology changes.
However, it is massively scalable.
Install
npm i upring-pubsub --save
Usage
const upring = require('upring')({
base: process.argv.slice(2),
hashring: {
joinTimeout: 200
}
})
upring.use(require('upring-pubsub'))
var count = 0
upring.on('up', function () {
console.log('copy and paste the following in a new terminal')
console.log('node example', this.whoami())
upring.pubsub.on('hello/world', function (msg, cb) {
console.log(msg)
cb()
})
setInterval(function () {
count++
upring.pubsub.emit({
topic: 'hello/world',
count,
pid: process.pid
})
}, 1000)
})
API
new UpRingPubSub(opts)
See MQEmitter for the actual API.
Acknowledgements
This project is kindly sponsored by nearForm.
License
MIT