ClusterWorker
Defined in: packages/sharding/src/worker.ts:29
The worker side of a cluster. It tells the parent when the process is
ready, answers the parent’s requests, and asks the parent for IDENTIFY
slots. ShardManager uses it automatically inside a cluster; use it
directly when you run your own Gateways.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ClusterWorker(
context,endpoint?,options?):ClusterWorker
Defined in: packages/sharding/src/worker.ts:64
Parameters
Section titled “Parameters”context
Section titled “context”endpoint?
Section titled “endpoint?”WorkerEndpoint = ...
options?
Section titled “options?”(code) => void
Replaces process.exit; for tests.
exitOnParentLoss?
Section titled “exitOnParentLoss?”boolean
Exit when the parent’s IPC channel closes. Without a parent nothing coordinates IDENTIFY or fences this process, and its Gateway sessions would keep running beside a replacement. Default: true for the real process, false for an injected endpoint.
Returns
Section titled “Returns”ClusterWorker
Properties
Section titled “Properties”context
Section titled “context”
readonlycontext:ClusterContext
Defined in: packages/sharding/src/worker.ts:52
Accessors
Section titled “Accessors”identifyGate
Section titled “identifyGate”Get Signature
Section titled “Get Signature”get identifyGate():
IdentifyGate|undefined
Defined in: packages/sharding/src/worker.ts:99
The gate to use when the parent coordinates IDENTIFY, otherwise undefined.
Returns
Section titled “Returns”IdentifyGate | undefined
Methods
Section titled “Methods”close()
Section titled “close()”close():
void
Defined in: packages/sharding/src/worker.ts:144
Stops listening and rejects pending IDENTIFY requests.
Returns
Section titled “Returns”void
onRequest()
Section titled “onRequest()”onRequest(
type,handler):this
Defined in: packages/sharding/src/worker.ts:136
Answers requests of type sent with ClusterManager.requestCluster().
The return value (or thrown error) goes back to the caller.
Parameters
Section titled “Parameters”string
handler
Section titled “handler”RequestHandler
Returns
Section titled “Returns”this
ready()
Section titled “ready()”ready(
shardIds?):void
Defined in: packages/sharding/src/worker.ts:123
Tells the parent every shard of this process finished its handshake.
Parameters
Section titled “Parameters”shardIds?
Section titled “shardIds?”readonly number[] = ...
Returns
Section titled “Returns”void
reportHealth()
Section titled “reportHealth()”reportHealth(
report):void
Defined in: packages/sharding/src/worker.ts:128
Pushes a health report to the parent without being asked.
Parameters
Section titled “Parameters”report
Section titled “report”Returns
Section titled “Returns”void
current()
Section titled “current()”
staticcurrent():ClusterWorker|undefined
Defined in: packages/sharding/src/worker.ts:33
The worker of this process, or undefined when it was not forked by a ClusterManager.
Returns
Section titled “Returns”ClusterWorker | undefined
reset()
Section titled “reset()”
staticreset():void
Defined in: packages/sharding/src/worker.ts:47
Forgets the process-wide worker (tests).
Returns
Section titled “Returns”void