-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: add multiprovider #78
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
MockProvidertest 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]>
fabriziodemaria
left a comment
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
fabriziodemaria
left a comment
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 👍
🤖 I have created a release *beep* *boop* --- ## [0.5.0](0.4.0...0.5.0) (2025-11-12) ### ⚠ BREAKING CHANGES * add provider event details ([#77](#77)) ### 🐛 Bug Fixes * Prevent race condition on updateContext ([#84](#84)) ([dd23929](dd23929)) ### ✨ New Features * add multiprovider ([#78](#78)) ([869b90a](869b90a)) * add provider event details ([#77](#77)) ([56b477e](56b477e)) * add Tracking API ([#81](#81)) ([c14b0cd](c14b0cd)) * Allow FlagEvaluationDetails to be a public API ([#79](#79)) ([0b07a8f](0b07a8f)) ### 📚 Documentation * Update docs with ImmutableContext ([#72](#72)) ([28ccd3e](28ccd3e)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…w outputs (#92) <!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> Latest GitHub Release/SPM Version: [0.5.0](https://github.com/open-feature/swift-sdk/releases/tag/0.5.0) Latest Published CocoaPods Version: 0.3.0 (because [the workflow has been getting skipped during releases](https://github.com/open-feature/swift-sdk/actions/runs/19297891762)) <img width="1626" height="107" alt="image" src="https://github.com/user-attachments/assets/5678eec0-ba7f-49c2-b6ff-e6adf7e053a8" /> - fixes CocoaPods publishing by correcting release-please workflow outputs which were causing publication to be skipped - removes incorrect namespace prefix from workflow outputs (`OpenFeature--release_created` → `release_created`) - updates comment to align with behavior for simple release type with root path ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> Fixes #91 ### Notes <!-- any additional notes for this PR --> The workflow was incorrectly using namespaced outputs like `steps.release.outputs['OpenFeature--release_created']`, but the simple release type with root path (`.`) doesn't actually namespace outputs. This caused the CocoaPods job condition to evaluate to false, skipping publication. Verified by examining workflow logs from the 0.5.0 release which show actual outputs are `release_created`, `version`, etc. without namespace prefixes. ``` % gh run list --workflow release-please.yaml --limit 3 STATUS TITLE WORKFLOW BRANCH EVENT ID ELAPSED AGE ✓ chore(deps): update amannn/action-semantic-pull-request action to v6 … Run Release Please main push 19442473525 16s about 17 days ago ✓ chore: update copyright and gitignore (#88) Run Release Please main push 19442153404 23s about 17 days ago ✓ chore(main): release 0.5.0 (#73) Run Release Please main push 19297891762 17s about 22 days ago % gh run view 19297891762 --log | grep -A10 -B10 "release_created\|Dump Release Please Output" release-please UNKNOWN STEP 2025-11-12T12:45:25.8719301Z ❯ targetBranch: main release-please UNKNOWN STEP 2025-11-12T12:45:25.8721712Z ❯ commits: 0 release-please UNKNOWN STEP 2025-11-12T12:45:25.8725336Z ✔ Considering: 0 commits release-please UNKNOWN STEP 2025-11-12T12:45:25.8726276Z ✔ No commits for path: ., skipping release-please UNKNOWN STEP 2025-11-12T12:45:25.8955456Z ##[group]Run echo "$RELEASE_PLEASE_OUTPUT" release-please UNKNOWN STEP 2025-11-12T12:45:25.8955895Z echo "$RELEASE_PLEASE_OUTPUT" release-please UNKNOWN STEP 2025-11-12T12:45:25.8993497Z shell: /usr/bin/bash -e {0} release-please UNKNOWN STEP 2025-11-12T12:45:25.8993806Z env: release-please UNKNOWN STEP 2025-11-12T12:45:25.8999929Z RELEASE_PLEASE_OUTPUT: { release-please UNKNOWN STEP "releases_created": "true", release-please UNKNOWN STEP "release_created": "true", release-please UNKNOWN STEP "id": "261739650", release-please UNKNOWN STEP "name": "v0.5.0", release-please UNKNOWN STEP "tag_name": "0.5.0", release-please UNKNOWN STEP "sha": "d71686219a65ab78f77923ceb0e2ea549e1e50ef", release-please UNKNOWN STEP "body": "## [0.5.0](0.4.0...0.5.0) (2025-11-12)\n\n\n### ⚠ BREAKING CHANGES\n\n* add provider event details ([#77](https://github.com/open-feature/swift-sdk/issues/77))\n\n### 🐛 Bug Fixes\n\n* Prevent race condition on updateContext ([#84](#84)) ([dd23929](https://github.com/open-feature/swift-sdk/commit/dd239294e127ebf598f38227e4b9a85447576aff))\n\n\n### ✨ New Features\n\n* add multiprovider ([#78](#78)) ([869b90a](https://github.com/open-feature/swift-sdk/commit/869b90a7bf0c98368fe5b49f6c852178ba299ad7))\n* add provider event details ([#77](#77)) ([56b477e](https://github.com/open-feature/swift-sdk/commit/56b477e69250bc52feab0c9838234843d83b5732))\n* add Tracking API ([#81](#81)) ([c14b0cd](https://github.com/open-feature/swift-sdk/commit/c14b0cd6624c04801d16a801e4cf3412d522e4bd))\n* Allow FlagEvaluationDetails to be a public API ([#79](#79)) ([0b07a8f](https://github.com/open-feature/swift-sdk/commit/0b07a8ff1e790fe57de4608ff7ae2edaa8fdb48d))\n\n\n### 📚 Documentation\n\n* Update docs with ImmutableContext ([#72](#72)) ([28ccd3e](28ccd3e))", release-please UNKNOWN STEP "html_url": "https://github.com/open-feature/swift-sdk/releases/tag/0.5.0", release-please UNKNOWN STEP "draft": "false", release-please UNKNOWN STEP "upload_url": "https://uploads.github.com/repos/open-feature/swift-sdk/releases/261739650/assets{?name,label}", release-please UNKNOWN STEP "path": ".", release-please UNKNOWN STEP "version": "0.5.0", release-please UNKNOWN STEP "major": "0", release-please UNKNOWN STEP "minor": "5", release-please UNKNOWN STEP "patch": "0", release-please UNKNOWN STEP "paths_released": "[\".\"]" release-please UNKNOWN STEP } release-please UNKNOWN STEP 2025-11-12T12:45:25.9006547Z ##[endgroup] ... ``` ### Follow-up Tasks <!-- anything that is related to this PR but not done here should be noted under this section --> <!-- if there is a need for a new issue, please link it here --> - Update the `COCOAPODS_TRUNK_TOKEN` repository secret with a fresh trunk token [as described in OWNERS.md](https://github.com/open-feature/swift-sdk/blob/main/OWNERS.md) if hasn't been kept up to date - The token expires every 128 days, and the `0.3.0` release was a while ago ``` % bundle exec pod trunk info OpenFeature OpenFeature - Versions: - 0.3.0 (2024-05-23 16:00:30 UTC) - Owners: - OpenFeature <[email protected]> ``` ### How to test <!-- if applicable, add testing instructions under this section --> - Monitor next release to confirm CocoaPods publishing works Signed-off-by: Sameeran Kunche <[email protected]>
This PR
FirstMatchStrategyandFirstSuccessfulStrategyimplementationsRelated Issues
#68
Follow-up Tasks
How to test