Examples

Example 1

import { createApplication } from '@setu-ts/kernel';
import { RuntimePlugin } from '@setu-ts/runtime';
import { RealtimeBackplanePlugin } from '@setu-ts/realtime-backplane-plugin';
import { WebSocketPlugin } from '@setu-ts/websocket-plugin';

const app = createApplication({
  plugins: [
    RuntimePlugin(),
    RealtimeBackplanePlugin({ transport: 'redis', url: 'redis://localhost:6379' }),
    WebSocketPlugin(),
  ],
});

Classes

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

A real single-process backplane.

c
MessagingBackplane(
broker: IMessageBroker,
origin: string,
topic: string
)

Carries frames over whatever broker is registered under CAPABILITIES.MESSAGING.

c
RedisBackplane(
options: RedisBackplaneOptions,
origin: string,
topic: string
)

Carries frames over Redis pub/sub.

c
RedisModuleError(message: string)

Thrown when ioredis cannot be loaded or does not look like itself.

Functions

f
adaptRedisModule(module: unknown): IRedisModule

Narrows an ioredis module to the constructor facade this package uses.

f
decodeFrameData(payload: EncodedPayload): string | Uint8Array

Decodes a payload received from the wire back into its local form.

f
encodeFrameData(data: string | Uint8Array): EncodedPayload

Encodes a WebSocket payload for the wire.

Interfaces

I
BackplaneCommonOptions

Options shared by every transport arm.

  • localNotice: boolean

    M70n X3-4: when the resolved transport is 'memory', the plugin logs a process-local notice at register() — frames fan out only within this process, which looks like partial delivery behind more than one replica. Default true; false suppresses the notice, matching the existing scalingNotice opt-out shape on the SSE and WebSocket plugins.

  • origin: string

    This instance's identity, stamped on published frames so a subscriber can drop its own echoes. Defaults to a fresh runtime.uuid(), which is correct for every deployment; override only to make a test deterministic.

  • topic: string

    The broker topic / Redis channel every instance publishes and subscribes on. Defaults to 'setu-ts.realtime'. Instances must agree on it to see each other.

I
CustomBackplaneOptions

Options for the 'custom' arm — a caller-supplied transport.

I
EncodedPayload

A payload as it travels the backplane.

I
IRealtimeBackplane

A publish/subscribe transport carrying RealtimeFrames between application instances.

I
IRedisBackplaneClient

The ioredis-shaped client surface the Redis transport uses.

I
IRedisModule

A module exposing an ioredis-compatible constructor.

I
MemoryBackplaneOptions

Options for the 'memory' arm — a real single-process transport, not a no-op. Instances sharing one process see each other; separate processes do not.

  • bus: string

    The name of the process-wide bus this instance joins. Two backplanes built with the same name exchange frames; different names are isolated, which is what keeps concurrent tests from bleeding into each other. Defaults to 'default'.

  • transport: "memory"

    Transport discriminant.

I
MessagingBackplaneOptions

Options for the 'messaging' arm, which carries frames over whatever broker is registered under CAPABILITIES.MESSAGING.

I
RealtimeFrame

One broadcast crossing the backplane.

I
RedisBackplaneOptions

Options for the 'redis' arm — Redis pub/sub.

Type Aliases

Variables

v
CAPABILITIES: { RUNTIME: string; LOGGER: string; CONFIG: string; VALIDATION: string; DATABASE: string; CACHE: string; EVENTS: string; MESSAGING: string; AUTH: string; AUTHORIZATION: string; JWT: string; SCHEDULER: string; METRICS: string; HEALTH: string; OPENAPI: string; TELEMETRY: string; SECRETS: string; AUDIT: string; RESILIENCE: string; STORAGE: string; MAIL: string; NOTIFICATION: string; FEATURE_FLAGS: string; QUEUE: string; CQRS: string; COMMAND_BUS: string; QUERY_BUS: string; MULTI_TENANCY: string; WORKER_POOL: string; DI_CONTAINER: string; HTTP_ADAPTER: string; SSE: string; WEBSOCKET: string; REALTIME_BACKPLANE: string; SSR: string; SESSION: string; SERVICE_DISCOVERY: string; HEALTH_INDICATOR: string; METRIC_REGISTRATION: string; OPENAPI_SCHEMA: string; CLI_COMMAND: string; DECORATOR_HANDLER: string; METADATA_STORE: string; GRPC: string; CLOUDFLARE: string; GRAPHQL: string; STATIC_FILES: string; VIEW: string; }

Standard capability tokens provided by the first-party plugins.

v
DEFAULT_TOPIC: "setu-ts.realtime"

The default topic when none is configured.

Usage

import * as __setu_ts_realtime_backplane_plugin____cross_replica_fan_out_for_WebSocket_rooms_and_SSE_channels___The_WebSocket_and_SSE_plugins_hold_their_broadcast_membership_in_ordinary_in_process_sets__correct_and_fast_on_one_instance__invisible_to_every_other__This_plugin_registers_an___linkcode_IRealtimeBackplane__under__CAPABILITIES_REALTIME_BACKPLANE___which_both_of_those_plugins_resolve___optionally_____so_registering_it_is_what_makes__ws_room__lobby____and__sse_channel__news____reach_clients_connected_to_a_different_replica__and_removing_it_returns_them_to_in_process_behavior_with_no_application_change___Three_transports_ship____memory____the_default__a_real_single_process_bus_____messaging____over_whatever_broker_is_registered_under__CAPABILITIES_MESSAGING___reusing_all_five_of_the_messaging_plugin_s_brokers_with_no_new_dependency___and___redis____Redis_pub_sub_over_an_inject_or_lazy__ioredis____A___custom___arm_accepts_any__IRealtimeBackplane____Two_caveats_are_structural_rather_than_incidental___Room_size__and__SseChannel_size__keep_reporting___local___membership__and__RoomBroadcastOptions_except__is_honored_only_on_the_originating_instance__because_it_names_a_live_in_process_connection_with_no_cross_process_identity__ from "realtime-backplane-plugin/src/index.ts";