-
-
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: remove datastores and implement Managers #3696
Conversation
- Base manager - GuildChannelManager - MessageManager - PresenceManager - Reaction Manager - Added LimitedCollection
- Most of the integration has been finished - TODO typings - Removed LRUCollection, needless sweeping
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.
Initial, obvious typos/nits
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.
Really great PR! It achieves the points set out in #3485. Most of my complaints are just nitpicks over documentation conventions, I found very few logical errors 😄 🎉
- Some inconsistencies with capitalisation of data structures
- Some descriptions include "the cache of this Manager" whereas others include the specific structure, e.g. "the role cache of this Manager"
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.
Just some minor corrections I have for the docs
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.
message.reactions.clear();
of line 16 in src/client/actions/MessageReactionRemoveAll.js
should be message.reactions.cache.clear();
This reverts commit bbdbc4c.
* Initial commit: add 5 initial managers - Base manager - GuildChannelManager - MessageManager - PresenceManager - Reaction Manager - Added LimitedCollection * Add GuildEmojiManager, various fixes * Modify some managers and add guildmembermanager * Initial integration * Delete old stores * Integration part two, removed LRUCollection - Most of the integration has been finished - TODO typings - Removed LRUCollection, needless sweeping * Typings + stuff i somehow missed in ChannelManager * LimitedCollection typings/ final changes * Various jsdoc and syntactical fixes, Removed Util.mixin() * tslint fix * Grammatical and logical changes * Delete temporary file placed by mistake * Grammatical changes * Add missing type * Update jsdoc examples * fix: ChannelManager#remove should call cache#delete not cache#remove * fix recursive require * Fix missed cache in util * fix: more missed cache * Remove accidental _fetchMany change from discordjs#3645 * fix: use .cache.delete() over .remove() * fix: missing cache in ReactionCollector * fix: missed cache in client * fix: members is a collection not a manager Co-Authored-By: Sugden <[email protected]> * fix: various docs and cache fixes * fix: missed cache * fix: missing _roles * Final testing and debugging * LimitedCollection: return the Collection instead of undefined on .set * Add cache to BaseManager in typings * Commit fixes i forgot to stage yesterday * Update invite events * Account for new commit * fix: MessageReactionRemoveAll should call .cache.clear() * fix: add .cache at various places, correct return type * docs: remove mentions of 'store' * Add extra documented properties to typings Co-authored-by: Sugden <[email protected]> Co-authored-by: SpaceEEC <[email protected]>
This reverts commit 7e8197c.
Please describe the changes this PR makes and why it should be merged:
This PR completely removes DataStores, and it implements Managers. The reasons for this change are highlighted in #3485, and this pr mostly implements it.
Testing
Due to the inherent breaking nature of this PR, it is not completely testable by one person. if you would like to aid in testing this pr, simply install the branch with:
npm i git://github.com/RDambrosio016/discord.js.git#remove-datastores
. If you encounter any weird behavior or errors, please either comment below, or ping me on the discord server (@BorgerKing#1856
).The main focus of the PR is completely separating API and cache for data models.
This allows us to:
Future plans
This pr easily allows us to give users control over caching strategies through dependency injection. Users will extend collection and provide it to a helper class similar to
Structures
which the managers will use to get the right collection. In addition to this, bans will be made into their own manager, this will centralize the methods so as not to have them in various managers and structures.Misc changes
Symbol.species
ofCollection
anymore.BaseManager
class isabstract
unlikeDataStore
.BaseManager
class, nor standalone managers extendCollection
.MessageManager#channel
.MessageStore#remove()
has been renamed toMessageManager#delete()
Managers!
Abstract:
DataStore
=>BaseManager
Extends
BaseManager
:GuildChannelStore
=>GuildChannelManager
GuildEmojiStore
=>GuildEmojiManager
GuildMemberStore
=>GuildMemberManager
MessageStore
=>MessageManager
PresenceStore
=>PresenceManager
ReactionStore
=>ReactionManager
GuildStore
=>GuildManager
ReactionUserStore
=>ReactionUserManager
UserStore
=>UserManager
RoleStore
=>RoleManager
Standalone (
cache
is a getter):GuildMemberRoleStore
=>GuildMemberRoleManager
GuildEmojiRoleStore
=>GuildEmojiRoleManager
todo
Rethink if Standalone stores should/could be reworked to extendBaseManager
.Check over typings to see if they are fully correct.Test if docs work fine.Change jsdoc to remove references to stores/ use managers properlyStatus
Semantic versioning classification:
This PR includes significant breaking changes to both how users interact with cache, and how internals interact with the cache. It also renames some methods such as
MessageStore#remove()
.