fix(gateway): wrong calculation in calculateWorkerId() (#4096)

* Update manager.ts

Fix wrong calculation of workerId

* Update manager.ts

* spread incrementally

* fix usage of incorrect variable

---------

Co-authored-by: Awesome Stickz <awesome@stickz.dev>
This commit is contained in:
qreepex
2025-01-31 00:50:41 +05:30
committed by GitHub
co-authored by Awesome Stickz
parent 10731a180a
commit 153408f286
+1 -1
View File
@@ -271,7 +271,7 @@ export function createGatewayManager(options: CreateGatewayManagerOptions): Gate
)
},
calculateWorkerId(shardId) {
const workerId = Math.min(shardId % gateway.shardsPerWorker, gateway.totalWorkers - 1)
const workerId = Math.min(Math.floor(shardId / gateway.shardsPerWorker), gateway.totalWorkers - 1);
gateway.logger.debug(
`[Gateway] Calculating workerId: Shard: ${shardId} -> Worker: ${workerId} -> Per Worker: ${gateway.shardsPerWorker} -> Total: ${gateway.totalWorkers}`,
)