Global API#54
Conversation
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
…tdown logic to re-initialize everithing to the default state. Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Summary of ChangesHello @NeaguGeorgiana23, 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 significantly advances the OpenFeature C++ SDK by introducing its foundational API components. It establishes a robust global entry point ( Highlights
Using Gemini Code AssistThe 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 by creating a comment using either
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces the core OpenFeatureAPI singleton, which is a significant and well-structured addition to the C++ SDK. The overall design, including the separation of concerns into ClientAPI and GlobalContextManager, is sound and employs good practices for thread safety and API design. My review includes a few suggestions: two critical fixes for the new test files that would otherwise cause build failures, and two medium-severity recommendations to enhance code clarity and efficiency. Overall, this is a solid contribution.
| // Re-initialize to the default state after shutting down | ||
| std::shared_ptr<openfeature::NoopProvider> noop_provider = | ||
| std::make_shared<NoopProvider>(); | ||
| absl::StatusOr<std::unique_ptr<FeatureProviderStatusManager>> status_manager = | ||
| FeatureProviderStatusManager::Create(noop_provider); | ||
| if (status_manager.ok()) { | ||
| default_manager_ = std::move(status_manager.value()); | ||
| default_manager_->SetStatus(ProviderStatus::kReady); | ||
| } |
There was a problem hiding this comment.
The Shutdown() method re-initializes the repository with a NoopProvider. While this is correct for explicit shutdowns via the API, it's inefficient when Shutdown() is called from the ~ProviderRepository() destructor, as the object is about to be destroyed.
A better approach would be to avoid this re-initialization in the destructor. This could be done by parameterizing the Shutdown method. For example:
// In provider_repository.h
void Shutdown(bool reinitialize = true);
// In provider_repository.cpp
ProviderRepository::~ProviderRepository() {
Shutdown(false);
}
void ProviderRepository::Shutdown(bool reinitialize) {
// ... existing shutdown logic ...
if (reinitialize) {
// ... re-initialization logic from lines 119-127 ...
}
}Since this change spans multiple files and locations, I'm not providing a direct code suggestion. Please consider this refactoring to improve efficiency and adhere to best practices for destructors.
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
1f654b9 to
06b0169
Compare
Signed-off-by: NeaguGeorgiana23 <115723925+NeaguGeorgiana23@users.noreply.github.com>
This PR
Clientinstances.Related Issues
Fixes #29