class MemoryBackplane
implements IRealtimeBackplane
Since 0.2.0

A real single-process backplane.

This is the default transport, and deliberately not a no-op: an application that registers the plugin without configuring a transport gets working fan-out between backplanes in the same process. What it does not do is cross a process boundary — for that, configure 'messaging' or 'redis'.

Examples

Example 1

const a = new MemoryBackplane('node-a');
const b = new MemoryBackplane('node-b');
await a.connect();
await b.connect();
await b.subscribe((frame) => console.log(frame.name));
await a.publish({ kind: 'ws-room', origin: a.origin, name: 'lobby', data: 'hi' });

Constructors

MemoryBackplane(
origin: string,
bus?: string
)
Parameters
origin: string

This instance's identity

optional
bus: string = default

The process-wide bus name to join

Properties

readonly
handlerErrors: readonly Error[]

Errors thrown by subscribers during delivery, oldest first.

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>

Opens the underlying transport. Idempotent.

Since 0.2.0
isHealthy(): Promise<boolean>

M70c: a real single-process bus has no backend to be unreachable, so it is always reachable. There is no external dependency whose outage could make this transport down (M47).

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 { MemoryBackplane } from "realtime-backplane-plugin/src/index.ts";