pluv.io is in preview! Please wait for a v1.0.0 stable release before using this in production.

PubSub

Note: Currently PubSub's are supported for Node.js only.

You may want to run a single room across multiple servers to horizontally scale your API. For that a PubSub will be necessary to share the events, and Persistance will be necessary for syncing storage state across servers.

Usage Example

Let's step through how we'd setup a pubsub to our pluv.io API.

Installation

Install your PubSub and Persistance of your choosing:

# For the server
npm install @pluv/pubsub-redis @pluv/persistance-redis
# Peer-dependencies
npm install ioredis

Setup your PubSub and Persistance

Create your pluv.io instance with your selected PubSub and Persistance:

// server/io.ts

import { createIO } from "@pluv/io";
import { platformNode } from "@pluv/platform-node";
import { PubSubRedis } from "@pluv/pubsub-redis";
import { PersistanceRedis } from "@pluv/persistance-redis";
import { Redis } from "ioredis";

// Setup redis. You can also use a Redis Cluster
const redis = new Redis({
    /* redis config here */
});

export const io = createIO({
    platform: platformNode({
        persistance: new PersistanceRedis({ client: redis }),
        pubSub: new PubSubRedis({
            publisher: redis,
            subscriber: redis,
        }),
    }),
});

Available Libraries

Below are the available pubsubs and libraries written for pluv.io. Check the roadmap to see what other providers are to be supported in the future.

PubSubs

Persistances