-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new advanced docs page on manual sharding
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Manual Sharding | ||
|
||
Advanced users can use methods located in the `Nostrum.Shard.Supervisor` module | ||
to manually connect shards to the gateway as well as initiate manual disconnect | ||
and reconnects (attempting to `RESUME` sessions where possible). | ||
|
||
You can set the `num_shards` option in your `nostrum` application config to | ||
`:manual` to prevent Nostrum from automatically starting shards. You should use | ||
the methods in the shard supervisor such as `Nostrum.Shard.Supervisor.connect/2` | ||
to manually start shards if using this configuration option. | ||
|
||
## Reconnection example | ||
|
||
```elixir | ||
# On Node A | ||
iex> Nostrum.Shard.Supervisor.connect(0, 1) | ||
iex> resume_info = Nostrum.Shard.Supervisor.disconnect(0) | ||
%{shard_num: 0, ...} | ||
|
||
# On another node | ||
iex> Nostrum.Shard.Supervisor.reconnect(resume_info) | ||
``` | ||
|
||
Discord will perform a best effort attempt to resume the gateway from the time | ||
of disconnection, relaying any missed events. Note that this can result in some | ||
events being missed or some events being delivered twice. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters