upring-pubsub

0.3.0 • Public • Published

UpRingPubSub

npm version Build Status Coverage Status

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.

js-standard-style

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

Package Sidebar

Install

npm i upring-pubsub

Weekly Downloads

1

Version

0.3.0

License

MIT

Last publish

Collaborators

  • lucamaraschi
  • matteo.collina