Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

pull-redis-pubsub

2.0.3 • Public • Published

pull-redis-pubsub

Build Status

Simple wrapper to get redis pub sub channels as a pull stream.

subscriber

The subscriber is a pull stream source that will emit new messages over time.

publisher

The publisher is a pull stream sink that you can pipe new messages too.

install

npm install pull-redis-pubsub

example

Publisher

var redis_pub = require('pull-redis-pubsub').pub;
var pushable  = require('pull-pushable')
var pull      = require('pull-stream')
 
function publisher () {
    if (! (this instanceof publisher)) return new publisher ();
    this.buffer = new pushable;
    var self    = this;
    this.emit   = function (data) {
        self.buffer.push(JSON.stringify(data));
    }
    pull(
        this.buffer,
        redis_pub('cool_channel')
    )
}
 
var pub = publisher ()
 
setInterval(function () {
 
    pub.emit({
        demo: Math.random() // important data
    })
 
}, 1000)
 

Subscriber

var redis_sub = require('pull-redis-pubsub').sub;
var pull      = require('pull-stream')
 
pull(
    redis_sub('cool_channel'),
    pull.log()
)

install

npm i pull-redis-pubsub

Downloadsweekly downloads

0

version

2.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability