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:
1# For the server2npm install @pluv/pubsub-redis @pluv/persistance-redis3# Peer-dependencies4npm install ioredis yjs
Setup your PubSub and Persistance
Create your pluv.io instance with your selected PubSub and Persistance:
1// server/io.ts23import { createIO } from "@pluv/io";4import { platformNode } from "@pluv/platform-node";5import { PubSubRedis } from "@pluv/pubsub-redis";6import { PersistanceRedis } from "@pluv/persistance-redis";7import { Redis } from "ioredis";89// Setup redis. You can also use a Redis Cluster10const redis = new Redis({11 /* redis config here */12});1314export const io = createIO({15 platform: platformNode({16 persistance: new PersistanceRedis({ client: redis }),17 pubSub: new PubSubRedis({18 publisher: redis,19 subscriber: redis,20 }),21 }),22});
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.