UpRingPubSub
PubSub system built on top of an UpRing consistent hashring. UpRingPubSub is consistently available, so it can lose messages when the topology changes. However, it is massively scalable.
See MQEmitter for the actual API.
Install
npm i upring-pubsub --save
Usage
'use strict'
const UpRingPubsub = require('upring-pubsub')
const broker = UpRingPubsub({
base: process.argv.slice(2)
})
broker.on('#', function (msg, cb) {
console.log(msg)
cb()
})
broker.upring.on('up', function () {
console.log('copy and paste the following in a new terminal')
console.log('node example', this.whoami())
})
var count = 0
setInterval(function () {
count++
broker.emit({
topic: 'hello',
count,
payload: `from ${process.pid}`
})
}, 1000)
API
new UpRingPubSub(opts)
All the options of UpRing and MQEmitter, combined.
UpRingPubSub specific options:
upring
: an already initializedUpRing
instance that has not already emitted'up'
Acknowledgements
This project is kindly sponsored by nearForm.
License
MIT