feat(gateway): add stopGateway function (#2078)

* Move the shard stopping to gatewayManager in order to stop the gateway standalone.

* Update gateway/gateway_manager.ts

Co-authored-by: ITOH <to@itoh.at>

* Update gateway/stopGateway.ts

Co-authored-by: ITOH <to@itoh.at>

* Update gateway/stopGateway.ts

* Update gateway/stopGateway.ts

* Update gateway/stopGateway.ts

Co-authored-by: ITOH <to@itoh.at>
Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
Andreas Fink
2022-02-28 19:41:15 +01:00
committed by GitHub
parent 4aac2246ad
commit ad8a9920ac
3 changed files with 21 additions and 11 deletions
+4
View File
@@ -18,6 +18,7 @@ import {
import { resume } from "./resume.ts";
import { sendShardMessage } from "./sendShardMessage.ts";
import { prepareBuckets, spawnShards } from "./spawnShards.ts";
import { stopGateway } from "./stopGateway";
import { tellWorkerToIdentify } from "./tellWorkerToIdentify.ts";
import { DiscordenoShard } from "./shard.ts";
@@ -88,6 +89,7 @@ export function createGatewayManager(
handleOnMessage: options.handleOnMessage ?? handleOnMessage,
processGatewayQueue: options.processGatewayQueue ?? processGatewayQueue,
closeWS: options.closeWS ?? closeWS,
stopGateway: options.stopGateway ?? stopGateway,
sendShardMessage: options.sendShardMessage ?? sendShardMessage,
resume: options.resume ?? resume,
safeRequestsPerShard: options.safeRequestsPerShard ?? safeRequestsPerShard,
@@ -209,6 +211,8 @@ export interface GatewayManager {
processGatewayQueue: typeof processGatewayQueue;
/** Closes shard WebSocket connection properly. */
closeWS: typeof closeWS;
/** Use this function to stop the gateway properly. */
stopGateway: typeof stopGateway;
/** Properly adds a message to the shards queue. */
sendShardMessage: typeof sendShardMessage;
/** Properly resume an old shards session. */