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 adds support for code injection at 3 stages of the gateway service start-up process.

This allows you to do more complex tasks, such as modifying the behaviour of the cluster, custom orchestration and the possibility of recovering from full crashes thanks to #60

GATEWAY_INJECTION_TOKENS is an object exported by the @cordis/common package which is used to store values into the global tsyringe container you can access in your extension.

Assuming the "root" is this location in the repo, the gateway service will look into a directory named "extensions" for the following files:

  • pre-setup - ran right after parsing configuration options. The only available token is kConfig. If you're doing something like custom orchestration and need to dynamically mess with startingShard or other properties, now's the time to do it!
  • pre-init - ran after AMQP connection is complete, all of the needed objects are constructed and after event listeners are attached to the cluster instance, but before the connection to Discord is established. If you want to mess around with cluster behaivour or to attach extra listeners, now's probably the time to do it, as all of the tokens available at this point.
  • post-init - ran after a successful connection of all of the shards under the given cluster and the RoutingServer is ready to distribute packets. If you have something that depends on those or want to set up some clean up, do it now. All symbols are still available at this stage.

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)

tbnritzdoge
tbnritzdoge previously approved these changes Mar 13, 2021
tbnritzdoge
tbnritzdoge previously approved these changes Mar 13, 2021
zaida04
zaida04 previously approved these changes Mar 13, 2021
@didinele didinele dismissed stale reviews from zaida04 and tbnritzdoge via 87a2601 March 13, 2021 15:29
@zaida04 zaida04 merged commit 01fad06 into main Mar 13, 2021
@zaida04 zaida04 deleted the feat/gateway-service-injection branch March 13, 2021 15:31
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