This repository has been archived by the owner on Jan 8, 2022. It is now read-only.
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:
I heard you wanted a nice and complete sharder. 👀
Sadly, this system is not compatible with [email protected], but it will be for a future version! This sharder draws inspiration from the strategy and plug-in system Sapphire has largely adopted over the months, the way Kurasuta handles messages and shards separately, and the structure of Discord.js's built-in sharding manager to make the update easy, alongside a few sprinkles of my own based on my experience when building a cross-process intercommunication system.
Let's talk about this sharder's structure! It is divided in three components:
WorkerShardHandler
) and forks (ForkProcessShardHandler
) to cross-server clusters going thru local clusters (ClusterProcessShardHandler
). Yes, you heard that. Although we'll most likely ship only the 3 local ones. You can make your own custom shard strategies.RawMessageHandler
(data as-is, without converting to a Buffer or a string),JsonMessageHandler
(JSON), andBinaryMessageHandler
(V8 serder)... You can plug in your own ones, such as the Erlang External Term Format (ETF), YAML, TOML, etc.This clear separation between responsibilities allow for greater customization of the core functionality of the library, reducing the need to use external libraries.
And coming in the future, we'll probably release The Message Mappers, which give a final touch-up to a message, such as appending a header/footer or even, using OpenSSL to encrypt messages over the network.
Issues to handle:
respawn: boolean
torespawn: number
, accepting-1
andInfinity
for unlimited respawns, but a number that is decreased by one on each shard until it's ready, in which case it'll reset the counter./gateway/bot
in the sharder, only once, and pass the data to the shards during spawn. We could also implement a query system so we can get that data from the ShardingManager without querying Discord more than once a day by caching and updating the result accordingly.Todo:
ProcessShardHandler
abstract, for the two classes below.ForkProcessShardHandler
.CusterProcessShardHandler
.WorkerShardHandler
.RawMessageHandler
.BinaryMessageHandler
.fetchRecommendedShards
.ShardTunnel
?ShardClient
?Status and versioning classification: