This repository was archived by the owner on Apr 17, 2023. It is now read-only.
feat(gateway-service): support code injection #61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_TOKENSis an object exported by the@cordis/commonpackage which is used to store values into the global tsyringecontaineryou 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 iskConfig. If you're doing something like custom orchestration and need to dynamically mess withstartingShardor 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 theclusterinstance, 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 theRoutingServeris 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: