npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

primus-rooms-redis-adapter

v2.3.17

Published

redis adapter for primus-rooms plugin. Supports omega-supreme and metroplex

Downloads

92

Readme

primus-rooms-redis-adapter

Build Status NPM version dependencies Status

Redis adapter for primus-rooms. Provides integration with metroplex and omega-supreme to allow for multiple servers support.

Installation

$ npm install primus-rooms-redis-adapter --save

Getting started

The adapter relies on ioredis for the redis connection, if an incorrect instance is provided the adapter will throw an error

'use strict';

var Primus = require('primus');
var Redis = require('ioredis');
var Adapter = require('primus-rooms-redis-adapter');

var redis = new Redis(/* options */);
var adapter = new Adapter(redis, {/* options */});

Once the adapter has been initialized it can be used to initialize the primus-rooms plugin.

// as an argument 
var primus = new Primus(http, {
  transformer: 'websockets',
  rooms: {adapter: adapter},
  plugin: {
    'rooms': require('primus-rooms'),
  },
});

// or by setting the property
primus.adapter = new Adapter();

Metroplex and Omega-Supreme Integration

If you are using metroplex and omega-supreme plugins, you can use the config function to allow the adapter to handle the broadcasting, removing and other things related to the multiple servers setup.

Example Metroplex and Omega-Supreme configuration

var options = {
  metroplexOmegaSupreme: true,
  primus: primus,
};

adapter.config(options, function(){
  console.log('clean exit');
});
// or 
primus.adapter.config(options);

API

new Adapter(redis, [options])

The constructor allows you to initialize the adapter. It requires an ioredis instance connected to a redis db.

The following (optional) options can be provided:

Name | Type | Description | Default -----------------------|----------|-------------------------------------------|--------------- namespace | String | namespace to use in redis storage | bumblebee metroplexOmegaSupreme | Boolean | Use omega-supreme to broadcast to all servers through metroplex | false

adapter.config([options], [cb])

Function to configure the adapter, allows for setting flags as well as enabling clean exit logic on app termination. To add the listeners for cleanExit a primus instance must be passed in.

Note: Preforming cleanExit can take a while especially if the http server timeout is set too high. The reason for that is due to node design, see issue #2642. I recommend setting http server timeout to based on the server load higher load longer time to finish up sending data to the user. To set the time out use require('http').createServer().setTimeout(x); where x is the timeout duration you want to allow a keep-alive request to be in idle before terminating it.

Name | Type |Description | Default -----------------------|----------|-------------------------------------------|--------------- metroplexOmegaSupreme | Boolean | Use omega-supreme to broadcast to all servers through metroplex | initilized value primus | Object | Primus instance to be used to preform clean exit| undefined cb | Function | Callback function after a clean exit is preformed | undefined