feat: Update provider - #121
Conversation
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <115723925+NeaguGeorgiana23@users.noreply.github.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds the ChangesProvider Hooks
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
openfeature/provider.h (1)
28-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winProvide a default implementation for
GetHooksto avoid breaking existing providers.Adding a new pure virtual method (
= 0) toFeatureProvideris a breaking change that will cause compilation failures for any existing third-party provider implementations. Since providing hooks is typically optional for a provider, consider providing a default implementation that returns an empty vector. This aligns with the approach taken forInitandShutdownand preserves backward compatibility.♻️ Proposed fix
- virtual std::vector<std::shared_ptr<BaseHook>> GetHooks() const = 0; + virtual std::vector<std::shared_ptr<BaseHook>> GetHooks() const { + return {}; + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openfeature/provider.h` at line 28, Update FeatureProvider::GetHooks to provide a default implementation returning an empty vector instead of declaring it pure virtual, matching the optional behavior of Init and Shutdown while preserving existing provider compatibility.openfeature/flag_evaluation_details.h (1)
25-26: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAdd an rvalue-reference constructor overload for
ResolutionDetails<T>. Consider adding an overload that takesResolutionDetails<T>&&to allow moving the resolution details instead of always copying them. Flag evaluations occur frequently, and bypassing the copy of heap-allocated structures likestd::stringandstd::unordered_map(insideFlagMetadata) will significantly reduce allocation overhead.
(Note: For this move to be fully effective, ensure thatResolutionDetails<T>also supports move semantics in the future by ensuring it doesn't unnecessarily define a destructor that suppresses implicit move operations).
openfeature/flag_evaluation_details.h#L25-L26: Add the declaration for the rvalue overload.FlagEvaluationDetails(std::string flag_key, const ResolutionDetails<T>& resolution_details); FlagEvaluationDetails(std::string flag_key, ResolutionDetails<T>&& resolution_details);
openfeature/flag_evaluation_details.cpp#L25-L29: Provide the corresponding implementation.template <typename T> FlagEvaluationDetails<T>::FlagEvaluationDetails( std::string flag_key, const ResolutionDetails<T>& resolution_details) : ResolutionDetails<T>(resolution_details), flag_key_(std::move(flag_key)) {} template <typename T> FlagEvaluationDetails<T>::FlagEvaluationDetails( std::string flag_key, ResolutionDetails<T>&& resolution_details) : ResolutionDetails<T>(std::move(resolution_details)), flag_key_(std::move(flag_key)) {}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openfeature/flag_evaluation_details.h` around lines 25 - 26, Add an rvalue-reference constructor overload to FlagEvaluationDetails<T> in openfeature/flag_evaluation_details.h at lines 25-26, accepting ResolutionDetails<T>&& alongside the existing const-reference overload. Implement the matching overload in openfeature/flag_evaluation_details.cpp at lines 25-29, move-constructing the ResolutionDetails<T> base and moving flag_key; ensure ResolutionDetails<T> retains implicit move support by avoiding an unnecessary destructor.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openfeature/flag_evaluation_details.cpp`:
- Around line 3-6: Add an explicit <utility> include alongside the existing
standard-library headers in flag_evaluation_details.cpp so the file directly
provides std::move without relying on transitive includes.
In `@openfeature/hook.h`:
- Around line 34-38: Update the virtual Before method in Hook to accept const
HookContext<T>&, enforcing the immutable hook-context contract and matching the
signatures of After, Error, and Finally. Update the corresponding Before
override in hook_test.cpp so it uses the same const-reference parameter and
continues to satisfy the interface.
---
Nitpick comments:
In `@openfeature/flag_evaluation_details.h`:
- Around line 25-26: Add an rvalue-reference constructor overload to
FlagEvaluationDetails<T> in openfeature/flag_evaluation_details.h at lines
25-26, accepting ResolutionDetails<T>&& alongside the existing const-reference
overload. Implement the matching overload in
openfeature/flag_evaluation_details.cpp at lines 25-29, move-constructing the
ResolutionDetails<T> base and moving flag_key; ensure ResolutionDetails<T>
retains implicit move support by avoiding an unnecessary destructor.
In `@openfeature/provider.h`:
- Line 28: Update FeatureProvider::GetHooks to provide a default implementation
returning an empty vector instead of declaring it pure virtual, matching the
optional behavior of Init and Shutdown while preserving existing provider
compatibility.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c117f5a-2248-4b2e-93be-1e737eabbfd8
📒 Files selected for processing (12)
openfeature/BUILDopenfeature/base_hook.hopenfeature/evaluation_options.hopenfeature/flag_evaluation_details.cppopenfeature/flag_evaluation_details.hopenfeature/hook.cppopenfeature/hook.hopenfeature/provider.htest/BUILDtest/evaluation_options_test.cpptest/flag_evaluation_details_test.cpptest/hook_test.cpp
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <115723925+NeaguGeorgiana23@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
openfeature/BUILD (2)
91-100: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winDefine the
base_hookBazel target before using it.All four dependencies require a target named
base_hook. Add a header-onlycc_libraryforbase_hook.hinopenfeature/BUILD.
openfeature/BUILD#L91-L100: definebase_hookbeforeevaluation_optionsconsumes it.openfeature/BUILD#L237-L237: keepnoop_providerdependent on the new target.openfeature/BUILD#L286-L286: keepproviderdependent on the new target.openfeature/memory_provider/BUILD#L24-L24: keep the absolute dependency after the target exists. (raw.githubusercontent.com)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openfeature/BUILD` around lines 91 - 100, Define a header-only cc_library target named base_hook for base_hook.h before evaluation_options in openfeature/BUILD, so its dependency is available. Preserve the existing dependency on the new target at openfeature/BUILD:237-237 for noop_provider, openfeature/BUILD:286-286 for provider, and openfeature/memory_provider/BUILD:24-24; these sites require no direct changes.Source: MCP tools
33-42: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDerive
GeneralHookfromBaseHook.
Hook<T>currently inherits fromGeneralHook, but provider hooks andEvaluationOptionsstore hooks asstd::shared_ptr<BaseHook>. MakeGeneralHookinherit fromBaseHook, includeopenfeature/base_hook.h, and add:base_hookto thegeneral_hookBazel target so concrete hooks are usable through the base hook interface.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openfeature/BUILD` around lines 33 - 42, Update the GeneralHook class to inherit from BaseHook, include openfeature/base_hook.h, and initialize the BaseHook subobject via :base_hook. Add the :base_hook dependency to the general_hook Bazel target so Hook<T>, provider hooks, and EvaluationOptions can use concrete hooks through std::shared_ptr<BaseHook>.Source: MCP tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openfeature/noop_provider.h`:
- Around line 27-29: Update FeatureProvider::GetHooks() to provide a non-pure
default implementation that returns an empty vector of hooks, while keeping
existing overrides valid so external providers remain source-compatible.
---
Outside diff comments:
In `@openfeature/BUILD`:
- Around line 91-100: Define a header-only cc_library target named base_hook for
base_hook.h before evaluation_options in openfeature/BUILD, so its dependency is
available. Preserve the existing dependency on the new target at
openfeature/BUILD:237-237 for noop_provider, openfeature/BUILD:286-286 for
provider, and openfeature/memory_provider/BUILD:24-24; these sites require no
direct changes.
- Around line 33-42: Update the GeneralHook class to inherit from BaseHook,
include openfeature/base_hook.h, and initialize the BaseHook subobject via
:base_hook. Add the :base_hook dependency to the general_hook Bazel target so
Hook<T>, provider hooks, and EvaluationOptions can use concrete hooks through
std::shared_ptr<BaseHook>.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 574fdea7-6b79-4103-bf6c-cbe427b0f503
📒 Files selected for processing (8)
openfeature/BUILDopenfeature/memory_provider/BUILDopenfeature/memory_provider/in_memory_provider.cppopenfeature/memory_provider/in_memory_provider.hopenfeature/noop_provider.cppopenfeature/noop_provider.htest/BUILDtest/mocks/mock_feature_provider.h
🚧 Files skipped from review as they are similar to previous changes (1)
- test/BUILD
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openfeature/provider.h`:
- Line 28: Update FeatureProvider::GetHooks so existing subclasses remain
instantiable by providing a default empty implementation instead of making the
method pure virtual. Preserve the current return type and const contract, and
avoid changing provider behavior for implementations that do override GetHooks.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 1ae2d828-9e52-4a56-9df7-eb90a90b3391
📒 Files selected for processing (11)
openfeature/BUILDopenfeature/evaluation_options.hopenfeature/memory_provider/BUILDopenfeature/memory_provider/in_memory_provider.cppopenfeature/memory_provider/in_memory_provider.hopenfeature/noop_provider.cppopenfeature/noop_provider.hopenfeature/provider.htest/BUILDtest/evaluation_options_test.cpptest/mocks/mock_feature_provider.h
🚧 Files skipped from review as they are similar to previous changes (6)
- openfeature/memory_provider/in_memory_provider.h
- openfeature/noop_provider.cpp
- openfeature/noop_provider.h
- test/mocks/mock_feature_provider.h
- openfeature/evaluation_options.h
- openfeature/memory_provider/in_memory_provider.cpp
Signed-off-by: NeaguGeorgiana23 <115723925+NeaguGeorgiana23@users.noreply.github.com>
…every provider needs to implement a logic for it. Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds provider-level hook support and verifies EvaluationOptions storage semantics via new unit tests.
Changes:
- Extends
FeatureProviderwith aGetHooks()API returningGeneralHookinstances. - Implements
GetHooks()forNoopProvider,InMemoryProvider, and updates the provider mock accordingly. - Introduces a new
evaluation_options_testBazel target with tests for hooks and hook hints.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/mocks/mock_feature_provider.h | Updates mock provider interface to include GetHooks() |
| test/evaluation_options_test.cpp | Adds unit tests for EvaluationOptions hooks and hook hints behavior |
| test/BUILD | Registers new test target and required deps |
| openfeature/provider.h | Adds GetHooks() pure virtual API to provider interface |
| openfeature/noop_provider.h / .cpp | Implements GetHooks() for the noop provider |
| openfeature/memory_provider/in_memory_provider.h / .cpp | Implements GetHooks() for in-memory provider |
| openfeature/memory_provider/BUILD | Adds general_hook dep for provider build |
| openfeature/BUILD | Adds general_hook deps to affected libraries |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…-sdk into update_provider
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
m-olko
left a comment
There was a problem hiding this comment.
You are adding here evaluation_options_test.cpp which you deleted in earlier PR. Other than that, LGTM
Thanks for pointing that out. I overlooked that. |
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
🤖 I have created a release *beep* *boop* --- ## [0.1.3](v0.1.2...v0.1.3) (2026-08-10) ### Features * Add EvaluationOptions structure ([#120](#120)) ([05c3eed](05c3eed)) * Add Hooks class ([#118](#118)) ([57f6c87](57f6c87)) * Update provider ([#121](#121)) ([4c1bb41](4c1bb41)) ### Bug Fixes * race condition between status check and provider lookup ([#108](#108)) ([59b2342](59b2342)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com>
This PR
GetHooksfunction to the FeatureProvider interfaceGetHooksfunction to all classes that inherit from FeatureProvider (InMemoryProvider,NoopProviderandMockFeatureProvider)Related Issues
Fixes #78