Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Conversation

@didinele
Copy link
Contributor

Please describe the changes this PR makes and why it should be merged:
This PR introduces support for resuming when initially connecting to the websocket.

This can be really useful in case of a gateway process crash, it allows reducing packet loss significantly and is overall a faster recovery.

Example:

// get some data from something like Redis with up-to-date sequence and sessionId for each shard
// your data should be in the following format:
// [
//   { sessionId: 'this_is_totally_valid', sequence: 129 },
//   { sessionId: 'this_is_also_valid', sequence: 200 }
// ]
// Where the index of the object is the index of the shard *local* to this cluster.
// To clarify, if you have 2 clusters - each 3 shards and this code is running in your second cluster,
// your arrray indeces should be 0, 1, 2 - representing Discord shards 3, 4 and 5
const data = getData();
await clusterInstance.connect(data);

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • This PR changes the library's interface (methods or parameters added)

zaida04
zaida04 previously approved these changes Mar 12, 2021
tbnritzdoge
tbnritzdoge previously approved these changes Mar 13, 2021
@didinele didinele dismissed stale reviews from tbnritzdoge and zaida04 via 6b29e35 March 13, 2021 15:26
@zaida04 zaida04 merged commit d0cf306 into main Mar 13, 2021
@zaida04 zaida04 deleted the feat/fresh-resume branch March 13, 2021 15:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants