feat: Add HookData class. #114
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>
|
Warning Review limit reached
Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds public flag and hook data types, implements ChangesHook data structures
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
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 |
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
openfeature/hook_data.h (1)
21-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider adding a const overload of
GetAsfor read-only contexts.Currently
GetAsis non-const only, which prevents typed retrieval from aconst HookData&. A const overload returningconst T*would improve API ergonomics for callers that only need read access.♻️ Optional: add const GetAs overload
template <typename T> T* GetAs(const std::string& key) { auto it_key = data_.find(key); if (it_key != data_.end()) { return std::any_cast<T>(&it_key->second); } return nullptr; } + + template <typename T> + const T* GetAs(const std::string& key) const { + auto it_key = data_.find(key); + if (it_key != data_.end()) { + return std::any_cast<T>(&it_key->second); + } + return nullptr; + }🤖 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/hook_data.h` around lines 21 - 28, Add a const overload of HookData::GetAs(const std::string& key) returning const T* so typed values can be retrieved from const HookData instances; preserve the existing non-const overload and use const access to data_ in the new implementation.
🤖 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.
Nitpick comments:
In `@openfeature/hook_data.h`:
- Around line 21-28: Add a const overload of HookData::GetAs(const std::string&
key) returning const T* so typed values can be retrieved from const HookData
instances; preserve the existing non-const overload and use const access to
data_ in the new implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b29e6623-cfa0-4781-ad37-8282518e3158
📒 Files selected for processing (7)
openfeature/BUILDopenfeature/flag_type_value.hopenfeature/hook_data.cppopenfeature/hook_data.hopenfeature/hook_hints.htest/BUILDtest/hook_data_test.cpp
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
This PR
HookData, the foundational state-management container required for the OpenFeature Hooks lifecycle specification (Section 4.6).std::unordered_map<std::string, std::any>(Set,Get, andGetAs<T>) to allow individual hook instances to persist arbitrary runtime state (e.g., execution timers, OpenTelemetry span pointers, transaction IDs) acrossBefore,After/Error,FinallyAfterstages during a single flag evaluation.Related Issues
Fixes #111
Follow-up Tasks
HookContext