@discordeno/gateway 21.0.0-next.bcd8d4d → 21.0.0-next.c4f2fc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/Shard.cjs +12 -8
- package/dist/cjs/manager.cjs +32 -58
- package/dist/esm/Shard.js +12 -8
- package/dist/esm/manager.js +33 -59
- package/dist/types/Shard.d.ts +5 -6
- package/dist/types/Shard.d.ts.map +1 -1
- package/dist/types/manager.d.ts +23 -4
- package/dist/types/manager.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/types/manager.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AtLeastOne, type BigString, type Camelize, type DiscordGetGatewayBot, type DiscordMemberWithUser, type DiscordUpdatePresence, type RequestGuildMembers } from '@discordeno/types';
|
|
2
|
-
import { Collection, logger } from '@discordeno/utils';
|
|
2
|
+
import { Collection, LeakyBucket, logger } from '@discordeno/utils';
|
|
3
3
|
import Shard from './Shard.js';
|
|
4
4
|
import { type ShardEvents, type ShardSocketRequest, type TransportCompression, type UpdateVoiceState } from './types.js';
|
|
5
5
|
export declare function createGatewayManager(options: CreateGatewayManagerOptions): GatewayManager;
|
|
@@ -39,6 +39,19 @@ export interface CreateGatewayManagerOptions {
|
|
|
39
39
|
* @default 4
|
|
40
40
|
*/
|
|
41
41
|
totalWorkers?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to spread shards across workers in a round-robin manner.
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* By default, shards are assigned to workers in contiguous blocks based on shardsPerWorker. If any shard is left over, it will be assigned to the last worker.
|
|
47
|
+
* This means that if you have 3 workers and 40 shards while shardsPerWorker is 10, the first worker will get shards 0-9, the second worker will get shards 10-19, and so on, the last worker will get shards 20-39.
|
|
48
|
+
*
|
|
49
|
+
* If this option is set to true, the shards will be assigned in a round-robin manner to spread more evenly across workers.
|
|
50
|
+
* For example, with 3 workers and 40 shards, the first shard will go to worker 0, the second shard to worker 1, the third shard to worker 2, the fourth shard to worker 0, and so on.
|
|
51
|
+
*
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
spreadShardsInRoundRobin?: boolean;
|
|
42
55
|
/** Important data which is used by the manager to connect shards to the gateway. */
|
|
43
56
|
connection?: Camelize<DiscordGetGatewayBot>;
|
|
44
57
|
/** Whether incoming payloads are compressed using zlib.
|
|
@@ -142,8 +155,8 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
|
142
155
|
id: number;
|
|
143
156
|
queue: number[];
|
|
144
157
|
}>;
|
|
145
|
-
/**
|
|
146
|
-
|
|
158
|
+
/** The bucket to queue the identifies. */
|
|
159
|
+
leakyBucket: LeakyBucket;
|
|
147
160
|
}>;
|
|
148
161
|
/** The shards that are created. */
|
|
149
162
|
shards: Map<number, Shard>;
|
|
@@ -185,7 +198,13 @@ export interface GatewayManager extends Required<CreateGatewayManagerOptions> {
|
|
|
185
198
|
/** Shutdown all shards. */
|
|
186
199
|
shutdown: (code: number, reason: string, clearReshardingInterval?: boolean) => Promise<void>;
|
|
187
200
|
sendPayload: (shardId: number, payload: ShardSocketRequest) => Promise<void>;
|
|
188
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* Allows users to hook in and change to communicate to different workers across different servers or anything they like.
|
|
203
|
+
* For example using redis pubsub to talk to other servers.
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* This should wait for the worker to have identified the shard before resolving the returned promise
|
|
207
|
+
*/
|
|
189
208
|
tellWorkerToIdentify: (workerId: number, shardId: number, bucketId: number) => Promise<void>;
|
|
190
209
|
/** Tell the manager to identify a Shard. If this Shard is not already managed this will also add the Shard to the manager. */
|
|
191
210
|
identify: (shardId: number) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/manager.ts"],"names":[],"mappings":"AACA,OA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;IACb,2DAA2D;IAC3D,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,qBAAqB,EAAE,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAA;IAC5G,8DAA8D;IAC9D,OAAO,EAAE,qBAAqB,EAAE,CAAA;CACjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discordeno/gateway",
|
|
3
|
-
"version": "21.0.0-next.
|
|
3
|
+
"version": "21.0.0-next.c4f2fc2",
|
|
4
4
|
"main": "./dist/esm/index.js",
|
|
5
5
|
"types": "./dist/types/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"test:test-type": "tsc --project tests/tsconfig.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@discordeno/types": "21.0.0-next.
|
|
38
|
-
"@discordeno/utils": "21.0.0-next.
|
|
37
|
+
"@discordeno/types": "21.0.0-next.c4f2fc2",
|
|
38
|
+
"@discordeno/utils": "21.0.0-next.c4f2fc2",
|
|
39
39
|
"ws": "^8.18.0"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|