Skip to content

ClusterHost

Defined in: packages/sharding/src/host.ts:81

The agent that makes a machine part of a deployment. It connects to the coordinator, starts the worker script for the clusters the coordinator places here, and relays their IPC frames both ways. The coordinator’s ClusterManager supervises those workers exactly like local ones.

Fencing: when the connection closes, or the coordinator stays silent for a whole lease, the host kills every worker at once. The coordinator waits longer than that before it restarts the clusters elsewhere, so a shard is never owned in two places.

new ClusterHost(options): ClusterHost

Defined in: packages/sharding/src/host.ts:107

ClusterHostOptions

ClusterHost

get connected(): boolean

Defined in: packages/sharding/src/host.ts:149

Whether the coordinator has accepted this host and the link is open.

boolean

close(): Promise<void>

Defined in: packages/sharding/src/host.ts:207

Kills every worker, closes the connection and stops reconnecting.

Promise<void>


clusters(): number[]

Defined in: packages/sharding/src/host.ts:154

Cluster IDs running on this host.

number[]


connect(): Promise<void>

Defined in: packages/sharding/src/host.ts:195

Connects and resolves once the coordinator accepts this host. After that, a lost connection is retried with backoff until close.

Promise<void>

If the first attempt is refused (bad secret, unknown or duplicate ID).


off<E>(event, listener): this

Defined in: packages/sharding/src/host.ts:170

Stops listening for a host event.

E extends keyof ClusterHostEvents

E

(…args) => void

this

This host.


on<E>(event, listener): this

Defined in: packages/sharding/src/host.ts:159

Listens for a host event.

E extends keyof ClusterHostEvents

E

(…args) => void

this

This host.