New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rpc-pubsub

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rpc-pubsub

A set of handlers for rpc-over-ws for PUBSUB using Redis' PUBSUB to scale out.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

A set of handlers for rpc-over-ws for PUBSUB using Redis' PUBSUB to scale out.

Installation

npm i --save rpc-pubsub

Usage

const Redis = require('ioredis')
const redis = new Redis(process.env.REDIS_URL)
const {publish, subscribe, unsubscribe, disconnected, emitter} = require('rpc-pubsub')(redis)

const {server} = require('rpc-over-ws')({ publish, subscribe, unsubscribe })
server.on('client-disconnect', client => disconnected(client))

Handlers

Note that "this" (the remote client) must be authenticated already with .clientId and .alias set before these handlers will work.

  subscribe({channel})       -> Promise<void>
  publish({channel, data})   -> Promise<void>
  unsubscribe({channel})     -> Promise<void>

Notifications

Clients are sent the following JSON when a message is published to a channel on which they are subscribed.

{
  "module": "pubsub",
  "type": "message",
  "channel": string,
  "alias": string,
  "data": any,
  "timestamp": int
}

Events

  • subscribe (client, channel)
  • unsubscribe (client, channel)
  • publish (client, channel, data)

Notes

There is no store-and-forward. A client must be connected and subscribed to be sent messages published to a channel.

Keywords

PUBSUB

FAQs

Package last updated on 10 Nov 2016

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