-
Notifications
You must be signed in to change notification settings - Fork 22
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: implemented LRU caching for flagd provider #47
Conversation
6af11db
to
e6c79f2
Compare
test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs
Outdated
Show resolved
Hide resolved
I think your testing strategy is fine. I find the tests around caching about as readable as possible given the complexity. They look similar to the ones in other contribs. I think my only request with them is that you add timeouts to every It would be even better to add a |
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.
Thanks @toddbaert for your review and suggestions - I agree with all of them, and will try to include them into this PR |
8c71dde
to
ffba3f2
Compare
alright, I have submitted all changes/suggestions, so the PR should be ready for another review :) |
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
ffba3f2
to
18fddbc
Compare
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.
lgtm!
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com> Signed-off-by: Vladimir Petrusevici <vladimir.petrusevici@outlook.com>
Closes #37
This PR implements standard caching functionality for the flagd provider. The configuration is done via the following env vars:
When caching is enabled, the flagd provider will establish an
EventStream
with the flagd server via grpc, and listen forconfiguration_change
events. When such an event is received for a flag that has already been cached previously, that flag will be removed from the cache. When retrieving the value of a feature flag, the value will be cached if theReason
of the resolution is set toSTATIC
.Note: The imported version of the OF dotnet-sdk is set to
0.5
- Since this version does not yet include theconfiguration_change
event type, or theSTATIC
reason type for the resolutionDetails, it might be worth to consider bumping the version of the imported dotnet-sdk as a follow up task.Note: Since the Event Stream is opened in a background task, I was not quite sure how to best verify in the Unit tests that things like the removal of a cached item were properly called by the provider. Coming from Golang, I was missing something like
require.Eventually(t, len(mockCache.DeleteCalls) == 1)
. I tried to resemble that behaviour by creating anAutoResetEvent
that gets set in the mock implementation of the method I would like to ensure it was called. Then, usingAssert.True(_autoResetEvent.WaitOne())
I waited for the event to be triggered. This solution does seem to work, but if there is a better approach to this in C# I appreciate every input from the reviewers of this PR