-
Notifications
You must be signed in to change notification settings - Fork 33
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: client in memory provider #617
feat: client in memory provider #617
Conversation
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.
I didn't have a chance to give it a detailed review but I wanted to provide some quick feedback. Overall, it looks good but I had a few questions. Also, would it be possible to share some of the logic across client and server? @toddbaert is working on publishing the shared components right now. Perhaps that work could be leveraged here.
packages/client/src/provider/in-memory-provider/in-memory-provider.ts
Outdated
Show resolved
Hide resolved
packages/client/src/provider/in-memory-provider/in-memory-provider.ts
Outdated
Show resolved
Hide resolved
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.
This looks good to me!
Left some comments, mainly regarding the usage of the cache.
Please correct me if I see something wrong here.
packages/client/src/provider/in-memory-provider/in-memory-provider.ts
Outdated
Show resolved
Hide resolved
packages/client/src/provider/in-memory-provider/in-memory-provider.ts
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #617 +/- ##
=========================================
- Coverage 99.07% 0 -99.08%
=========================================
Files 69 0 -69
Lines 2821 0 -2821
Branches 310 0 -310
=========================================
- Hits 2795 0 -2795
+ Misses 26 0 -26 ☔ View full report in Codecov by Sentry. |
Hey folks! Thanks for the feedback. Based on what you said, I'm planning on:
What do you think about that? @beeme1mr @lukas-reining |
Is this for supporting various test use cases? |
Sound good to me @luizgribeiro :) |
👍
👍
I think this might add confusion. It's easy enough to make a testing provider to test this stuff, but because this is all "in-memory", I don't expect a lot of complexity around statuses. The only things I would expect in this care are When implementing the in-memory provider, we should keep in mind 2 things:
|
Hey @luizgribeiro, it looks like there are some merge conflicts since we moved some files to |
Hey @beeme1mr! Sure, I'll probably have some time to work on this during the weekend. |
e3f6c87
to
c44b8f8
Compare
I've just pushed a newer version that instead of caching flag resolution it works based on the points mentioned above and store context internally to make it easier to test (even though it can also use context provided in resolution). Sorry for taking too long on this |
Signed-off-by: Todd Baert <[email protected]>
c44b8f8
to
601582c
Compare
packages/client/src/provider/in-memory-provider/in-memory-provider.ts
Outdated
Show resolved
Hide resolved
packages/client/src/provider/in-memory-provider/in-memory-provider.ts
Outdated
Show resolved
Hide resolved
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.
Hey @luizgribeiro ! This latest work looks great. I did however revert all changes that weren't /client
. My reasoning is threefold:
- this is a
feat
only for client, so we need to scope our changes there so the release automation only makes changes there - artifacts specific to the in-memory provider, such as the
VariantFoundError
and theFlagConfiguration
andFlag
types cannot be exported from shared, or I think they will really confuse people. These are only implementation details for the in-memory provider, and not part of the actual SDK API. The only thing we should export is the in-memory provider itself. - in addition to being useful in tests, this serves as an example, so a bit of duplication between client/server isn't bad in this case, IMO
I made only a few actual changes to the provider itself, which I've noted here.
packages/client/src/provider/in-memory-provider/in-memory-provider.ts
Outdated
Show resolved
Hide resolved
packages/client/src/provider/in-memory-provider/variant-not-found-error.ts
Outdated
Show resolved
Hide resolved
packages/client/src/provider/in-memory-provider/variant-not-found-error.ts
Outdated
Show resolved
Hide resolved
@beeme1mr good idea. I will do this generally. |
…und-error.ts Co-authored-by: Michael Beemer <[email protected]> Signed-off-by: Todd Baert <[email protected]>
…und-error.ts Co-authored-by: Michael Beemer <[email protected]> Signed-off-by: Todd Baert <[email protected]>
Signed-off-by: Todd Baert <[email protected]>
Thanks again @luizgribeiro . I will merge this if you don't have any objections to my changes to your branch. |
That looks good @toddbaert! Fell free to merge it 🚀 |
🤖 I have created a release *beep* *boop* --- ## [0.4.6](web-sdk-v0.4.5...web-sdk-v0.4.6) (2023-11-21) ### 🐛 Bug Fixes * make hooks in client sdk only return void ([#671](#671)) ([a7d0b95](a7d0b95)) ### ✨ New Features * client in memory provider ([#617](#617)) ([6051dfd](6051dfd)) ### 🧹 Chore * **main:** release core 0.0.19 ([#676](#676)) ([b0cbeb4](b0cbeb4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Signed-off-by: OpenFeature Bot <[email protected]>
This PR
Related Issues
Closes #565
Notes
It's a first try. Any feedback and enhancement proposals are welcome :)
How to test
Automated/unit testes were implemented, but e2e tests wouldn't hurt.