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 Persistence 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 Persistence of your choosing:

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

Setup your PubSub and Persistence

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

// server/io.ts

import { createIO } from "@pluv/io";
import { platformNode } from "@pluv/platform-node";
import { PubSubRedis } from "@pluv/pubsub-redis";
import { PersistenceRedis } from "@pluv/persistence-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({
        persistence: new PersistenceRedis({ 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

Persistences