refactor: merge both shard systems

This commit is contained in:
Skillz4Killz
2021-04-04 12:47:02 +00:00
committed by GitHub
parent 181bdffb41
commit 535f27c734
20 changed files with 488 additions and 574 deletions
+18
View File
@@ -0,0 +1,18 @@
import { ws } from "./ws.ts";
/** Allows users to hook in and change to communicate to different clusters across different servers or anything they like. For example using redis pubsub to talk to other servers. */
export async function tellClusterToIdentify(
workerID: number,
shardID: number,
bucketID: number
) {
// When resharding this may exist already
const oldShard = ws.shards.get(shardID);
// TODO: Use workers
await ws.identify(shardID, ws.maxShards);
if (oldShard) {
oldShard.ws.close(4009, "Resharded!");
}
}