@@ -6,42 +6,44 @@ If your bot's shards are multi-processed, then a good choice is to use the
6
6
[ Gateway Queue] . The Gateway Queue is a lightweight but powerful application
7
7
that you can host to queue shards across all of your processes.
8
8
9
- The Gateway Queue is library and language agnostic: it's an HTTP server that you
9
+ The Gateway Queue is library and language agnostic, it's an HTTP server that you
10
10
call whenever a shard needs to reconnect to the gateway.
11
11
12
12
### How it works
13
13
14
- When one of your shards disconnects and needs to perform a full reconnect, then
15
- it needs to start a new session with the gateway. If you have multiple processes
16
- managing shards, then you may not have communication between these processes.
17
- The problems start to happen when multiple shards from these processes try to
18
- reconnect at the same time: all but 1 will get ratelimited .
14
+ When one of your shards disconnects and needs to perform a full reconnect, it
15
+ needs to start a new session with the gateway. If you have multiple processes
16
+ managing shards, you may not have communication between these processes. The
17
+ problems start to happen when multiple shards from these processes try to
18
+ reconnect at the same time, all but 1 will get rate-limited .
19
19
20
20
This is because there's a 5 second ratelimit between new sessions. By sending an
21
21
HTTP request to the Gateway Queue, it will ratelimit the requests and "stall"
22
22
them, responding with a friendly message once that shard can reconnect:
23
23
24
24
``` json
25
- {"message" : " You're free to connect now! :)" }
25
+ {
26
+ "message" : " You're free to connect now! :)"
27
+ }
26
28
```
27
29
28
30
### Example
29
31
30
- The API is pretty minimal, probably . It's just an HTTP request:
32
+ The API is pretty minimal. It's just an HTTP request:
31
33
32
34
``` rust
33
35
reqwest :: get (" http://gateway-queue" ). await ? ;
34
36
```
35
37
36
- No headers, body, or particular method need to be set. They 're all ignored.
38
+ No headers, body, or particular method need to be set, they 're all ignored.
37
39
The request will get a response once the request has gone through the queue.
38
40
39
41
### Using with large bots
40
42
41
- If the bot has access to bucketed identify you will have to make slight
43
+ If the bot has access to bucketed identify, you will have to make slight
42
44
configuration changes. Firstly you will need to set the ` DISCORD_TOKEN `
43
- environment variable so it is able to fetch the remaining identifies and what
44
- the ` max_concurrency ` is. Secondly you will need to set the query parameter
45
+ environment variable so that it is able to fetch the remaining identifies and what
46
+ the ` max_concurrency ` is. Secondly, you will need to set the query parameter
45
47
` shard ` to the ID of the identifying shard.
46
48
47
49
``` rust
0 commit comments