interface IRealtimeBackplane
Since 0.2.0

A publish/subscribe transport carrying RealtimeFrames between application instances.

Examples

Example 1

const backplane = ctx.services.get<IRealtimeBackplane>(
  CAPABILITIES.REALTIME_BACKPLANE,
);
await backplane.subscribe((frame) => {
  if (frame.kind === 'sse-channel') {
    hub.channel(frame.name).publishLocal(JSON.parse(frame.data));
  }
});

Properties

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

connect(): Promise<void>

Opens the underlying transport. Idempotent.

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.

close(): Promise<void>

Closes the underlying transport and drops every handler.

Since 0.2.0
optional
isHealthy(): Promise<boolean>

Reports whether the transport's backend is reachable right now, for the plugin's health indicator.

Optional: a transport with no meaningful liveness check omits it, and the indicator then reports only the lifecycle state.

This answers a fact (reachability), not a policy: the indicator that consumes it owns the up/degraded/down mapping.

Usage

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