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

feat: blocking provider mutator #251

Conversation

Kavindu-Dodan
Copy link
Contributor

This PR

  • Add SetProviderAndWait & SetNamedProviderAndWait with blocking provider mutators
  • Improve non-eventing provider registration by emitting ready event : This can be considered as a fix as this is defined in spec but was missing in the implementation 1

The provider MAY define a status field/accessor which indicates the readiness of the provider, with possible values NOT_READY, READY, STALE, or ERROR.

Providers without this field can be assumed to be ready immediately.

Related Issues

Fixes #240

How to test

Tests were added to cover new APIs and old tests were updated to handle readiness emitted for non eventing providers

Footnotes

  1. https://openfeature.dev/specification/sections/providers#requirement-242

@Kavindu-Dodan Kavindu-Dodan requested a review from a team as a code owner February 2, 2024 21:48
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (d2c1636) 81.61% compared to head (f71a91c) 81.42%.
Report is 1 commits behind head on main.

❗ Current head f71a91c differs from pull request most recent head bfd25a3. Consider uploading reports for the commit bfd25a3 to get more accurate results

Files Patch % Lines
openfeature/api.go 94.33% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #251      +/-   ##
==========================================
- Coverage   81.61%   81.42%   -0.19%     
==========================================
  Files          10       10              
  Lines        1142     1163      +21     
==========================================
+ Hits          932      947      +15     
- Misses        192      196       +4     
- Partials       18       20       +2     

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

@toddbaert toddbaert self-requested a review February 6, 2024 17:29
Copy link
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good, code is clean. I think my only issue is that the set+wait function should return errors if the provider init fails, that's a key difference between the blocking and non-blocking setProvider functions.

Returning an error allows users to completely sidestep setting up error handers (though they can still do so optionally and we'd expect them to fire).

I think you should implement this and add a couple tests:

  • one that returns an error for an init after some delay
  • one that returns an error and also ensures error handlers are run.

Relavant PR language improvement (editorial, not significant): open-feature/spec#242

@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/blocking-provider-registration branch from 54ef5b0 to f71a91c Compare February 6, 2024 19:54
@Kavindu-Dodan
Copy link
Contributor Author

This seems good, code is clean. I think my only issue is that the set+wait function should return errors if the provider init fails, that's a key difference between the blocking and non-blocking setProvider functions.

Returning an error allows users to completely sidestep setting up error handers (though they can still do so optionally and we'd expect them to fire).

I think you should implement this and add a couple tests:

  • one that returns an error for an init after some delay
  • one that returns an error and also ensures error handlers are run.

Relavant PR language improvement (editorial, not significant): open-feature/spec#242

Done, addressed this concern in the latest commit. I added error return as well as test to validate error return as well as eventing

Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/blocking-provider-registration branch from f71a91c to bfd25a3 Compare February 6, 2024 19:58
@toddbaert toddbaert self-requested a review February 7, 2024 15:15
@Kavindu-Dodan Kavindu-Dodan merged commit 6f71fe4 into open-feature:main Feb 7, 2024
4 checks passed
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.

[FEATURE] Blocking provider mutator
4 participants