Shards and workers
Sharding splits gateway traffic across clients. Worker supervision handles the lifecycle of the processes or threads running your code. See the event guide for how they fit together.IdentifyLimiter
Import fromtalos-fluxer/shards. Construct
new IdentifyLimiter(limit?, windowMs?). The defaults allow 250 starts per
60-second rolling window. limit must be an integer from 1 to 300, and windowMs
must be positive. See the source.
Share a limiter across managers using the same source IP. For multiple processes,
provide a coordinated object with
acquire(signal) or use beforeIdentify.
These defaults describe Talos’s gate, not a guarantee of the instance’s quota.
ShardManager
Import fromtalos-fluxer/shards. new ShardManager(options) accepts the client
options plus count, identifyLimiter, and createClient. Its gateway options
exclude shard, which the manager sets for each client.
Without
count, the manager uses the API’s recommended shard count. It shares
one REST rate-limit store across clients and runs its Identify gate before every
Identify, including reconnects. A startup failure stops the created clients.
Use createClient to install listeners before each connection starts:
gateway.webSocket on Node 20.
WorkerSupervisor
Import fromtalos-fluxer/supervisor. new WorkerSupervisor(options) requires
count and spawn(id, { signal }). The spawn adapter returns a
SupervisedWorker with ready, closed, and stop().
See the source.
Inherited methods:
on, once, emit, removeAllListeners. Events are
ready: { id }, restart: { id, attempt }, error: unknown, and stopped with
no payload.
A worker exit after readiness triggers a restart, including a clean exit. The
restart budget is not reset by a successful restart. Exhausting it stops the
supervisor group. Initial startup failure also stops the group. Concurrent
stop() calls share cleanup.
nodeWorkerFactory(moduleURL, options?) from talos-fluxer/node supplies the
adapter for Node worker threads. Workers signal readiness with
parentPort.postMessage({ type: "talos:ready" }). See
the worker examples.