feat: support isolated API instances#171
feat: support isolated API instances#171marcozabel wants to merge 3 commits intoopen-feature:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #171 +/- ##
============================================
+ Coverage 95.19% 97.04% +1.84%
- Complexity 227 229 +2
============================================
Files 40 41 +1
Lines 583 575 -8
============================================
+ Hits 555 558 +3
+ Misses 28 17 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: marcozabel <marco.zabel@dynatrace.com>
de7631e to
08c9cbd
Compare
There was a problem hiding this comment.
Code Review
This pull request implements isolated OpenFeature API instances by changing the OpenFeatureAPI constructor to public and introducing a new OpenFeatureAPIFactory. This allows for independent API instances with their own providers, hooks, and contexts, fulfilling specification requirements. Feedback was provided regarding the unit tests, which currently interact with the global singleton; it is recommended to use multiple isolated instances in these tests to prevent global state pollution and potential test flakiness.
Signed-off-by: marcozabel <marco.zabel@dynatrace.com>
| * | ||
| * @see https://openfeature.dev/specification/sections/flag-evaluation#18-isolated-api-instances | ||
| */ | ||
| final class OpenFeatureAPIFactory |
There was a problem hiding this comment.
Section 1.8 is experimental in the spec. Worth adding an @experimental PHPDoc tag here so static analysis tools can flag it for consumers.
There was a problem hiding this comment.
This is not an official annotation in PHP, but has been used before in projects like Symfony.
We can add it all the same so that it is known this is experimental.
This PR
This PR introduces support for creating isolated OpenFeature API instances, each with their own providers, hooks, context, and event handling - enabling multi-tenant or side-by-side usage without shared global state.
Related Issues
Fixes #170
Notes
Follow-up Tasks
How to test