Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

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

install

npm i upring-pubsub

Downloadsweekly downloads

6

version

0.3.0

license

MIT

repository

githubgithub

last publish

collaborators

  • avatar
  • avatar