+
Skip to content

upringjs/upring-pubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UpRingPubSub

npm version Build Status Coverage Status

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.

js-standard-style

Install

npm i upring-pubsub

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 initialized UpRing instance that has not already emitted 'up'

Acknowledgements

This project is kindly sponsored by nearForm.

License

MIT

About

PubSub system built on top of UpRing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载