Skip to content
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

Impliment datastores to reduce boilerplate #629

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

Cooldude2606
Copy link
Member

@Cooldude2606 Cooldude2606 commented May 19, 2024

WIP feature, see #596 for details.

Main Objectives:

  • Reduce the number of things to remember when changing values to a single set or setMany call.
  • Fully handle the dirty flag within the class, no more checking before saving or setting after changes.
  • Create an interface that allows for formats other than JSON to be used.
  • Allow plugins to use the class without forcing the use of subscribable values.

Decisions Made:

  • There are two base classes BaseDatastore and DatastoreProvider one is an interface to plugins / controller the other provides the abilty to save and load data.
  • There are three providers implemented:
    • MemoryDatastoreProvider offers no abilty to save and load and is designed for testing or when saving is not required.
    • JsonDatastoreProvider saves the data as a JSON object, has the abilty to migrate and finalise data.
    • JsonIdDatastoreProvider saves the data as a JSON array where objects store their own id.
  • There are two datastores implemented:
    • Datastore the basic datastore that functions like a map.
    • SubscribableDatastore a datastore specialised to handle SubscribableValue
  • Get has readonly and mutable variations to nudge developers to only mutate when needed and to always call set.
  • The ModStore and UserManager have not been changed due to their complexity.

Copy link

codecov bot commented May 22, 2024

Codecov Report

Attention: Patch coverage is 65.26946% with 58 lines in your changes are missing coverage. Please review.

Project coverage is 76.64%. Comparing base (78a9f73) to head (94a07b5).
Report is 28 commits behind head on master.

Current head 94a07b5 differs from pull request most recent head 8b823a5

Please upload reports for the commit 8b823a5 to get more accurate results.

Files Patch % Lines
packages/lib/src/datastore.ts 64.51% 32 Missing and 1 partial ⚠️
packages/controller/src/Controller.ts 55.81% 19 Missing ⚠️
packages/controller/controller.ts 0.00% 2 Missing ⚠️
packages/controller/src/HostConnection.ts 88.23% 2 Missing ⚠️
packages/controller/src/InstanceInfo.ts 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #629      +/-   ##
==========================================
- Coverage   76.82%   76.64%   -0.19%     
==========================================
  Files         106      107       +1     
  Lines       10059    10070      +11     
  Branches     1664     1665       +1     
==========================================
- Hits         7728     7718      -10     
- Misses       1797     1824      +27     
+ Partials      534      528       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Cooldude2606 Cooldude2606 marked this pull request as ready for review May 25, 2024 17:18
@Cooldude2606 Cooldude2606 linked an issue May 25, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New lib class: KeyValueDatabase
1 participant