Skip to content

Cluster

Defined in: src/cluster/Cluster.ts:130

The Cluster is a single-instance “extension” attached to an ActorSystem. It owns a Transport, a gossip-based membership view, a failure detector and the plumbing that dispatches inbound envelope messages to local actors.

readonly selfAddress: NodeAddress

Defined in: src/cluster/Cluster.ts:131


readonly selfRoles: ReadonlySet<string>

Defined in: src/cluster/Cluster.ts:132


readonly system: ActorSystem

Defined in: src/cluster/Cluster.ts:133


readonly transport: Transport

Defined in: src/cluster/Cluster.ts:134

_onWire(kind, handler): () => void

Defined in: src/cluster/Cluster.ts:295

Register a handler for a specific wire-message discriminator.

string

(msg, from) => void

() => void


_registerEnvelopeHandler(path, handler): () => void

Defined in: src/cluster/Cluster.ts:276

Route envelopes addressed to path to handler. Returns unsubscribe.

string

EnvelopeHandler

() => void


_sendEnvelope(to, env): void

Defined in: src/cluster/Cluster.ts:289

Send an envelope to a remote node. Used by RemoteActorRef and by the PubSub / Singleton extensions. Any ActorRef embedded in the user payload is rewritten to a WireActorRef marker here — this is the single chokepoint where every cross-node message leaves, so hooking the encode step once covers all paths (sharding, pub-sub, singleton, direct remote-ref). Receiving nodes decode in handleEnvelope.

NodeAddress

EnvelopeMsg

void


_setEnvelopeHandler(handler): void

Defined in: src/cluster/Cluster.ts:271

Register a handler for inbound user envelopes. Kept for backward compatibility — prefer _registerEnvelopeHandler(path, handler) which allows multiple extensions (ClusterSharding, DistributedPubSub, …) to share the envelope pipeline.

EnvelopeHandler

void


down(addr): boolean

Defined in: src/cluster/Cluster.ts:314

Operator-initiated force-down of a remote peer (#56). Mirrors the private evaluateDowning path: marks the peer down, emits the lifecycle events, tombstones with removedAt so stale gossip can’t resurrect it, and tells the failure detector to forget it.

Returns true if a member was found and downed, false if the address was unknown or already terminal (down/removed).

Intended for operator tooling — the management HTTP endpoint POST /cluster/down calls this directly. Don’t use it as a replacement for the failure detector / downing provider in normal flow; it’s a manual override.

string | NodeAddress

boolean


getMembers(): readonly Member[]

Defined in: src/cluster/Cluster.ts:233

Current snapshot of known members. removed entries are kept internally as tombstones (so stale gossip can’t resurrect them via the merge path) but are filtered out here — the public contract is “members the cluster currently considers part of the topology”.

readonly Member[]


isLeader(): boolean

Defined in: src/cluster/Cluster.ts:261

True if this node is currently the leader.

boolean


leader(): Option<Member>

Defined in: src/cluster/Cluster.ts:255

The oldest up-member is the cluster leader (deterministic across nodes).

Option<Member>


leave(): Promise<void>

Defined in: src/cluster/Cluster.ts:336

Gracefully leave the cluster (broadcast leave, stop transport).

Promise<void>


reachableMembers(): Member[]

Defined in: src/cluster/Cluster.ts:245

Reachable members (up + joining + leaving).

Member[]


subscribe(listener): () => void

Defined in: src/cluster/Cluster.ts:203

Subscribe to membership events. The listener is immediately replayed the current cluster state as a series of Member/SelfUp events so that late subscribers still see the world they joined.

(event) => void

() => void


upMembers(): Member[]

Defined in: src/cluster/Cluster.ts:238

Members in the up state, ordered by address — the “active set”.

Member[]


upMembersWithRole(role): Member[]

Defined in: src/cluster/Cluster.ts:250

Up members that carry the given role tag.

string

Member[]


static join(system, settings): Promise<Cluster>

Defined in: src/cluster/Cluster.ts:192

Entry point: start the cluster and attempt to contact seed nodes.

ActorSystem

ClusterSettings

Promise<Cluster>