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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ClusterHost(
options):ClusterHost
Defined in: packages/sharding/src/host.ts:107
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”ClusterHost
Accessors
Section titled “Accessors”connected
Section titled “connected”Get Signature
Section titled “Get Signature”get connected():
boolean
Defined in: packages/sharding/src/host.ts:149
Whether the coordinator has accepted this host and the link is open.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”close()
Section titled “close()”close():
Promise<void>
Defined in: packages/sharding/src/host.ts:207
Kills every worker, closes the connection and stops reconnecting.
Returns
Section titled “Returns”Promise<void>
clusters()
Section titled “clusters()”clusters():
number[]
Defined in: packages/sharding/src/host.ts:154
Cluster IDs running on this host.
Returns
Section titled “Returns”number[]
connect()
Section titled “connect()”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.
Returns
Section titled “Returns”Promise<void>
Throws
Section titled “Throws”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.
Type Parameters
Section titled “Type Parameters”E extends keyof ClusterHostEvents
Parameters
Section titled “Parameters”E
listener
Section titled “listener”(…args) => void
Returns
Section titled “Returns”this
This host.
on<
E>(event,listener):this
Defined in: packages/sharding/src/host.ts:159
Listens for a host event.
Type Parameters
Section titled “Type Parameters”E extends keyof ClusterHostEvents
Parameters
Section titled “Parameters”E
listener
Section titled “listener”(…args) => void
Returns
Section titled “Returns”this
This host.