first commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Build the cross-process realtime bus from config. When realtime scaling is
|
||||
* enabled, room broadcasts are bridged over Redis pub/sub so they reach clients
|
||||
* on every app process/instance (multiple runs, or multiple apps behind the
|
||||
* gateway). Returns undefined when scaling is off (single-process realtime).
|
||||
*/
|
||||
|
||||
import type { RealtimeBus } from "@wrnexus/core";
|
||||
import { createPubSub } from "@wrnexus/pubsub";
|
||||
import { redisDriver } from "@wrnexus/pubsub/redis";
|
||||
|
||||
export function realtimeBusFromConfig(cfg?: {
|
||||
scale?: boolean;
|
||||
redisUrl?: string;
|
||||
}): RealtimeBus | undefined {
|
||||
if (!cfg?.scale && !cfg?.redisUrl) return undefined;
|
||||
return createPubSub(redisDriver(cfg.redisUrl));
|
||||
}
|
||||
Reference in New Issue
Block a user