Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
sse-broadcast-redis2
Advanced tools
Redis adapter for sse-broadcast clone with updated redis driver
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.
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.
const Adapter = require('sse-broadcast-redis')
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.
Circular reference to the adapter constructor for those who find require('sse-broadcast-redis').Adapter
more expressive.
The version string from package manifest.
const adapter = new Adapter(broadcaster)
Call the corresponding methods of internally used redis clients.
Delegated error
events of internal clients.
sse-broadcast-redis
is compatible with Node.js 0.12
and above.
With npm:
npm install sse-broadcast-redis
FAQs
Redis adapter for sse-broadcast clone with updated redis driver
We found that sse-broadcast-redis2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.