-
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.
Merge pull request #603 from Kraigie/jb3/docs/manual-sharding
Docs update: manual sharding
- Loading branch information
Showing
4 changed files
with
62 additions
and
21 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,27 @@ | ||
# 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. Resumption is not guaranteed to | ||
work, in the event it fails Nostrum will reconnect the shard from scratch, | ||
though this may mean some events are missed. |
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
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
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