redis-pubsub-relay
v1.1.0
Published
Relay EventEmitter to Redis Pub / Sub for the purpose of scalability of Node.js application.
Downloads
1
Readme
redis-pubsub-relay
Relay EventEmitter to Redis Pub / Sub for the purpose of scalability of Node.js application.
This module wraps any EventEmitter-extended classes, then event methods such as on
or emit
will be executed through Redis Pub / Sub.
Installation
$ npm install redis-pubsub-relay --save
Usage
const RedisPubSubRelay = require('../lib')
const relay = new RedisPubSubRelay()
const EventEmitter = require('events')
const WrappedEmitter = relay.wrap(EventEmitter)
const emitter = new WrappedEmitter()
emitter.on('something', (data) => {
console.log(data)
relay.quitClients()
})
emitter.onSubscribe('something', () => {
emitter.emit('something', {
number: 110,
string: 'foo',
null: null,
array: [],
date: new Date(),
})
})
API Guide
License
This software is released under the MIT License.