-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add multiprovider #78
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
base: main
Are you sure you want to change the base?
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.
Summary of Changes
Hello @jescriba, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a MultiProvider capability to the OpenFeature Swift SDK, allowing the client to evaluate feature flags by querying multiple underlying feature providers. It includes two distinct strategies, FirstMatchStrategy and FirstSuccessfulStrategy, to define how flag evaluations are aggregated and resolved across these providers. This implementation ports similar functionality from the OpenFeature Kotlin SDK.
Highlights
- MultiProvider Implementation: A new MultiProvider class is added, enabling the aggregation and evaluation of feature flags across a collection of FeatureProvider instances.
- FirstMatchStrategy: Introduces a strategy that iterates through providers, returning the first flag evaluation result that is not flagNotFound. If any other error occurs, it is propagated.
- FirstSuccessfulStrategy: Implements a strategy that returns the first successful flag evaluation result, ignoring errors from individual providers. An error is only thrown if all providers fail to return a successful evaluation.
- Asynchronous Initialization and Context Handling: The MultiProvider now supports asynchronous initialization and context updates, ensuring all wrapped providers are correctly configured.
- Unified Flag Evaluation: The MultiProvider leverages a generic evaluate function within its strategies to handle all supported flag types (Boolean, String, Integer, Double, Object) consistently.
- Provider Event Observation: The observe() method in MultiProvider merges event streams from all registered providers, allowing for consolidated event handling.
- Comprehensive Unit Tests: New unit tests are included to verify the behavior of the MultiProvider and its strategies under various conditions, including error handling and flag resolution.
- Mock Provider Utility: A MockProvider utility is added to simplify the testing of provider interactions and event flows.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
This pull request introduces a MultiProvider
feature, allowing the combination of multiple feature providers with different evaluation strategies (FirstMatchStrategy
and FirstSuccessfulStrategy
). This is a significant enhancement, effectively porting functionality from the Kotlin SDK. The implementation is well-structured, leveraging modern Swift features like async/await
and Combine
. The accompanying unit tests are thorough and cover various scenarios for the new strategies.
I have a couple of minor suggestions:
- Removing some unused properties in the new
MockProvider
test helper. - Improving the robustness of a test for observing provider events to avoid potential flakiness.
Overall, this is an excellent contribution. Once these minor points are addressed, this PR should be ready for merging.
Signed-off-by: jescriba <[email protected]>
Signed-off-by: jescriba <[email protected]>
Signed-off-by: jescriba <[email protected]>
Signed-off-by: jescriba <[email protected]>
cd4b55e
to
4863f2f
Compare
…der strategies Signed-off-by: jescriba <[email protected]>
c7b98f4
to
254cb55
Compare
Signed-off-by: jescriba <[email protected]>
de515d6
to
57e54a2
Compare
Signed-off-by: jescriba <[email protected]>
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 for the PR! My comments are nothing major, so I feel good clicking "approve" on my side 👍
Sources/OpenFeature/Provider/MultiProvider/FirstSuccessfulStrategy.swift
Outdated
Show resolved
Hide resolved
One more thing: I see the Kotlin SDK counterpart added a nice README about this new Provider. Could be nice to do the same here |
Signed-off-by: jescriba <[email protected]>
fdf75f0
to
f527a7b
Compare
Signed-off-by: jescriba <[email protected]>
Signed-off-by: jescriba <[email protected]>
Signed-off-by: jescriba <[email protected]>
53bb9d9
to
cf1baae
Compare
Good call - I updated the README with some multiprovider usage details. |
Signed-off-by: jescriba <[email protected]>
…ssfulStrategy Signed-off-by: jescriba <[email protected]>
Signed-off-by: jescriba <[email protected]>
Updated per comments 👍 Let me know if there are any more changes I should make |
Signed-off-by: Joshua E. <[email protected]>
Signed-off-by: jescriba <[email protected]>
d57a788
to
40f040e
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 👍
This PR
FirstMatchStrategy
andFirstSuccessfulStrategy
implementationsRelated Issues
#68
Follow-up Tasks
How to test