Neo's Personal Matrix

    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

    Last publish

    Collaborators

    • m-onz