class RedisBackplane
implements IRealtimeBackplane
Since 0.2.0

Carries frames over Redis pub/sub.

Two connections, deliberately. A Redis connection in subscriber mode refuses every command other than (un)subscribe, so publishing over the subscribed connection fails at runtime. That is a property of the Redis protocol rather than of ioredis, and it is invisible to any test driven with a single fake — hence the constructor refuses an injected client that arrives without its subscriber.

Examples

Example 1

app.register(RealtimeBackplanePlugin({
  transport: 'redis',
  url: 'redis://localhost:6379',
}));

Constructors

RedisBackplane(
origin: string,
topic: string
)
Parameters

The Redis arm's options

origin: string

This instance's identity

topic: string

The Redis channel every instance shares

Properties

readonly
handlerErrors: readonly Error[]

Errors thrown by subscribers during delivery, oldest first.

Since 0.2.0
optional
isHealthy: () => Promise<boolean>

M70c: present only when both connections expose status and ping; the indicator reads absence as unknown (a minimal fake that lacks the surface has not told us the backend is dead). A subscriber-mode connection refuses every command but (un)subscribe, so the pair is probed separately (M47's two-connection requirement).

readonly
origin: string

This instance's identity, stamped onto every frame it publishes.

Stable for the lifetime of the instance and distinct from every peer's.

Methods

close(): Promise<void>

Closes the underlying transport and drops every handler.

connect(): Promise<void>

Builds the client pair when needed, then subscribes.

Idempotent and safe to call concurrently: the open is memoized, so two overlapping calls join one attempt rather than each building — and leaking — its own pair of connections. A failed attempt leaves the instance unconnected with any connection it created already quit, and clears the memo so a later call retries. A close() arriving mid-attempt wins: the attempt retires whatever it built rather than publishing it.

publish(frame: RealtimeFrame): Promise<void>

Publishes a frame to every other subscribed instance.

The frame is not delivered back to this instance's own handlers — a local broadcast has already reached local members directly, and redelivering it would double-send.

subscribe(handler: RealtimeFrameHandler): Promise<() => void>

Registers a handler for frames arriving from other instances.

May be called more than once; each consumer plugin registers its own.

Usage

import { RedisBackplane } from "realtime-backplane-plugin/src/index.ts";