redis-pubsub-relay

1.1.0 • Public • Published

redis-pubsub-relay

npm Version JS Standard

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.

Readme

Keywords

Package Sidebar

Install

npm i redis-pubsub-relay

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

14.9 kB

Total Files

17

Last publish

Collaborators

  • fuji_haruka