Skip to content

ClusterSingletonManager

Defined in: src/cluster/singleton/ClusterSingletonManager.ts:73

Runs on every node. Watches cluster events and (re)spawns the singleton child when this node is the cluster leader; stops the child when it is not. Remote Envelopes addressed to the singleton land here and are forwarded to the child — if the manager is not on the leader node, the envelope is dropped with a warning (the proxy shouldn’t have forwarded there).

Two paths:

  • No lease (default). Synchronous reconcile — spawn the moment cluster gossip says we’re leader. Same behaviour the manager has shipped since v1.
  • With lease. Async reconcile that gates child-spawn on lease.acquire(), watches lease.onLost(...) for revocation, and release()s on graceful handover. All state transitions go through the manager’s own mailbox so concurrent cluster events can’t race with an in-flight acquire.

T

new ClusterSingletonManager<T>(settings): ClusterSingletonManager<T>

Defined in: src/cluster/singleton/ClusterSingletonManager.ts:99

ClusterSingletonManagerSettings<T>

ClusterSingletonManager<T>

Actor.constructor

_envelopeUnsub: (() => void) | null = null

Defined in: src/cluster/singleton/ClusterSingletonManager.ts:97

Callback the extension hands us so we can release the envelope path on stop.


readonly settings: ClusterSingletonManagerSettings<T>

Defined in: src/cluster/singleton/ClusterSingletonManager.ts:99

onReceive(msg): void | Promise<void>

Defined in: src/cluster/singleton/ClusterSingletonManager.ts:159

Main message handler. Receives each envelope dequeued from the mailbox. A thrown error (sync or async) is caught by the supervisor.

Inbox

void | Promise<void>

Actor.onReceive


postRestart(_reason): void | Promise<void>

Defined in: src/Actor.ts:55

Called on the fresh instance after a restart. Default: call preStart().

Error

void | Promise<void>

Actor.postRestart


postStop(): Promise<void>

Defined in: src/cluster/singleton/ClusterSingletonManager.ts:141

Called after the actor has been terminated. Children are already stopped.

Promise<void>

Actor.postStop


preRestart(_reason, _message?): void | Promise<void>

Defined in: src/Actor.ts:50

Called before a restart, on the instance about to be thrown away. The default stops children and then calls postStop().

Error

Inbox

void | Promise<void>

Actor.preRestart


preStart(): void

Defined in: src/cluster/singleton/ClusterSingletonManager.ts:101

Called after construction and before the first message is processed.

void

Actor.preStart


supervisorStrategy(): SupervisorStrategy

Defined in: src/Actor.ts:63

Supervisor strategy for this actor’s children. Defaults to restart, up to 10 times per minute, then stop.

SupervisorStrategy

Actor.supervisorStrategy