Placement, membership, health-check, and logging configuration. When a SfuClusterOptions.membership source is supplied, membership reconciliation starts immediately.
All nodes currently registered with the cluster, regardless of state.
Register a node with the cluster and begin listening for its overload events. Emits SfuClusterEvent.NodeAdded.
The node to add. Re-adding an existing id replaces its entry.
Select an active node for a room using the configured placement strategy.
Optionalregion: stringOptional preferred region for region-affinity placement.
Optionalkey: stringOptional routing key (for example a room id) for deterministic strategies.
The chosen node, or undefined when no active node is available.
Release cluster resources: stop membership reconciliation and health checks. Does not remove nodes or emit membership events.
Synchronously invokes every listener registered for event, in registration order.
true if at least one listener was invoked, false if there were none.
The listener list is snapshotted before dispatch, so mutations made by handlers take effect only on subsequent emissions. Listeners are isolated: if one throws, the remaining listeners still run and the error is surfaced via console.error rather than swallowed silently (consistent with LocalMessageBus).
Nodes eligible to serve traffic: those that are neither failed nor draining.
The active subset of SfuCluster.nodes.
Returns the number of listeners currently registered for event.
The event name to count listeners for.
The count of registered listeners (0 if none).
Registers a listener that is invoked at most once: it is removed automatically before
being called the first time event is emitted.
This emitter, for chaining.
Remove a pending one-time listener by passing the same function reference to off.
Invoke the SfuClusterOptions.onRebalance callback for every node that is currently draining or failed, so the host can migrate their rooms.
Emits SfuClusterEvent.Overloaded if at least one such node was found. Called automatically when a health check fails; may also be called manually.
Removes listeners for a single event, or for all events.
Optionalevent: keyof SfuClusterEventsThe event name to clear; if omitted, listeners for every event are removed.
This emitter, for chaining.
Remove a node from the cluster and detach its overload listener. Emits SfuClusterEvent.NodeRemoved when a node was removed.
Identifier of the node to remove.
true if a node was removed, false if no node had that id.
Start periodic health checks.
No-op unless a SfuClusterOptions.healthCheck onCheck probe was
configured. Each sweep probes every node; a node that fails is marked
failed, surfaces an SfuClusterEvent.Error, and triggers
SfuCluster.rebalance. A previously failed node that passes is
marked recovered.
Stop periodic health checks if they are running.
Manages a set of SfuNode instances and selects nodes for rooms via a pluggable PlacementStrategy.
The cluster can optionally reconcile its membership against an external Membership source and run periodic health checks that mark failing nodes as failed and trigger a rebalance. Placement always considers only active nodes — those that are neither failed nor draining.
Emits SfuClusterEvent events.
Example
Remarks
Call SfuCluster.dispose when the cluster is no longer needed to stop membership reconciliation and health checks.