-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: fetch gateway information without requiring rest in ws #10651
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10651 +/- ##
=======================================
Coverage 37.20% 37.21%
=======================================
Files 239 239
Lines 15147 15157 +10
Branches 1373 1377 +4
=======================================
+ Hits 5636 5640 +4
- Misses 9500 9505 +5
- Partials 11 12 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Just one classic mistake I've made a few times too, callbacks aren't encodeable over worker_threads, so this needs updating, otherwise we get hard crashes:
export interface FetchingStrategyOptions | |
extends Omit< | |
WebSocketManagerOptions, | |
| 'buildIdentifyThrottler' | |
| 'buildStrategy' | |
| 'rest' | |
| 'retrieveSessionInfo' | |
| 'shardCount' | |
| 'shardIds' | |
| 'updateSessionInfo' | |
> { | |
readonly gatewayInformation: APIGatewayBotInfo; | |
readonly shardCount: number; | |
} |
Along with its runtime counter-part:
export async function managerToFetchingStrategyOptions(manager: WebSocketManager): Promise<FetchingStrategyOptions> { | |
const { | |
buildIdentifyThrottler, | |
buildStrategy, | |
retrieveSessionInfo, | |
updateSessionInfo, | |
shardCount, | |
shardIds, | |
rest, | |
...managerOptions | |
} = manager.options; | |
return { | |
...managerOptions, | |
token: manager.token, | |
gatewayInformation: await manager.fetchGatewayInformation(), | |
shardCount: await manager.getShardCount(), | |
}; | |
} |
In the future I'll probably rewrite this to a Pick 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems the README and tests need updating
this needs a rebase now |
89c2b68
to
2626c9a
Compare
/** | ||
* The REST instance to use for fetching gateway information | ||
*/ | ||
rest?: REST; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we can deprecate (or remove) this 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont want this PR to become a major. We can re-deprecate it >.>
Please describe the changes this PR makes and why it should be merged:
Currently the only way to override the gateway URL that
/ws
will connect to is by intercepting the rest request and overriding it. This PR lets you pick a different ws url, if you may be proxying it or have custom implementations or what not.Status and versioning classification: