Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sse-broadcast-redis2

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sse-broadcast-redis2

Redis adapter for sse-broadcast clone with updated redis driver

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

view on npm downloads per month node version build status test coverage license

sse-broadcast-redis

Redis adapter for sse-broadcast.

SSE is a long-polling solution, consequently if you want to broadcast events to every client subscribed to a given channel then you’ll need some way of passing messages between processes or computers. This package distributes events across nodes on top of Redis.

Usage

const os      = require('os'),
      cluster = require('cluster')

if (cluster.isMaster)
    for (var i = os.cpus().length; i--;)
        cluster.fork()
else {
    const app = require('express')(),
          sse = require('sse-broadcast')()

    require('sse-broadcast-redis')(sse, { host: 'localhost', port: 6379 })

    app.get('/events', function (req, res) {
        sse.subscribe('channel', res)
    })

    app.post('/event', function (req, res) {
        sse.publish('channel', 'event', 'data')
        res.send()
    })

    app.listen(3333)
}

Note: options are passed to redis directly.

API

const Adapter = require('sse-broadcast-redis')

Adapter(broadcaster, [clientOrOptions])

Package's main export is the adapter constructor. Its first argument is a required Broadcaster instance, second is an optional redis client or an options object for redis.createClient(). See redis documentation regarding the available settings.

Adapter.Adapter

Circular reference to the adapter constructor for those who find require('sse-broadcast-redis').Adapter more expressive.

Adapter.version

The version string from package manifest.

const adapter = new Adapter(broadcaster)
adapter.unref(), adapter.quit() and adapter.end([flush])

Call the corresponding methods of internally used redis clients.

Event: 'error'

Delegated error events of internal clients.

Compatibility

sse-broadcast-redis is compatible with Node.js 0.12 and above.

Installation

With npm:

npm install sse-broadcast-redis

License

MIT

Keywords

FAQs

Package last updated on 05 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc