Skip to content

feat: add mechanism for open-close-principle to OpenFeatureApi #1015

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

Conversation

aepfli
Copy link
Member

@aepfli aepfli commented Jul 22, 2024

With this approach we allow people to modify the OpenFeatureApi Singleton.

The user can either provide an environment variable called OPEN_FEATURE_API_CLASS or a property file called openfeature.properties with which they can control the class, which will be used for instantiation.

first the environmental variable
second the properties file
third the default

(optional we could add system properties)

The provided class needs to extend OpenFeatureApi, and if we're not able to instantiate this class, we will fall to the default

This is just a proposal, of how we could add the open-close principle to the OpenFeatureApi, this approach could also work in other languages like python or c# - not sure of the others.

first we check an env var, if this is not set, we use a property file else we fallback

furthermore we fallback to the default if the provided class name can not be initialized

Signed-off-by: Simon Schrottner <[email protected]>
@aepfli aepfli force-pushed the proposal/open-close-principal branch from 5b28fd3 to 0ffb228 Compare July 22, 2024 19:37
Copy link

Copy link

codecov bot commented Jul 22, 2024

Codecov Report

Attention: Patch coverage is 53.33333% with 14 lines in your changes missing coverage. Please review.

Project coverage is 93.83%. Comparing base (3d0cd62) to head (0ffb228).

Files Patch % Lines
.../main/java/dev/openfeature/sdk/OpenFeatureAPI.java 53.33% 10 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1015      +/-   ##
============================================
- Coverage     95.04%   93.83%   -1.21%     
- Complexity      392      393       +1     
============================================
  Files            38       38              
  Lines           888      909      +21     
  Branches         54       58       +4     
============================================
+ Hits            844      853       +9     
- Misses           24       33       +9     
- Partials         20       23       +3     
Flag Coverage Δ
unittests 93.83% <53.33%> (-1.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@aepfli
Copy link
Member Author

aepfli commented Jul 23, 2024

after a night of sleep, i still think this is a feasible idea, but it will not help me in my endavours.

@aepfli aepfli closed this Jul 23, 2024
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.

1 participant