Skip to content

Global API#54

Merged
NeaguGeorgiana23 merged 5 commits into
mainfrom
feature/split-3-api
Jan 30, 2026
Merged

Global API#54
NeaguGeorgiana23 merged 5 commits into
mainfrom
feature/split-3-api

Conversation

@NeaguGeorgiana23

@NeaguGeorgiana23 NeaguGeorgiana23 commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

This PR

  • Implements the OpenFeatureAPI singleton class, which serves as the primary entry point for the OpenFeature C++ SDK.
  • Provides a global access point via GetInstance().
  • It implements a method to generate Client instances.

Related Issues

Fixes #29

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>
@NeaguGeorgiana23 NeaguGeorgiana23 requested review from a team as code owners January 27, 2026 13:10
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @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 (OpenFeatureAPI), enables the creation of client instances for feature flag evaluation (ClientAPI), and provides a mechanism for managing global evaluation contexts (GlobalContextManager). These changes are crucial for the SDK's functionality, allowing developers to interact with feature flags and providers in a structured and thread-safe manner, while also addressing a known issue related to the API's core structure.

Highlights

  • OpenFeatureAPI Implementation: The core OpenFeatureAPI singleton class has been implemented, serving as the central entry point for the C++ SDK. It provides global access via GetInstance() and methods to generate Client instances.
  • ClientAPI Introduction: A new ClientAPI class has been added, which handles client-specific flag evaluation, metadata retrieval, and manages client-level evaluation contexts. It currently supports boolean flag evaluation.
  • Global Context Management: The GlobalContextManager singleton has been introduced to manage the global evaluation context for the SDK in a thread-safe manner.
  • API Interface Refinements: The OpenFeature interface has been updated, removing SetProviderAndWait overloads with timeout parameters and adding const qualifiers to several Get methods for better API clarity and correctness. A GetProviderStatus method was also added to the interface.
  • Provider Repository Shutdown Behavior: The ProviderRepository::Shutdown method now ensures that after all providers are shut down, the repository is reset to its initial state with a default NoopProvider in a ready status.
  • Build System and Testing Updates: The .bazelversion has been updated to 7.4.1. New cc_library targets for the introduced API components and corresponding cc_test targets for ClientAPI, GlobalContextManager, and OpenFeatureAPI have been added to the BUILD files.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  1. 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 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.

Comment thread test/global_context_manager_test.cpp Outdated
Comment thread test/openfeature_api_test.cpp Outdated
Comment thread openfeature/client_api.h
Comment on lines +119 to +127
// 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);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

@NeaguGeorgiana23 NeaguGeorgiana23 changed the title Feature/split 3 api Global API Jan 27, 2026
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
This was referenced Jan 27, 2026

@oxddr oxddr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but let's have #52 and #53 merged first.

Signed-off-by: NeaguGeorgiana23 <115723925+NeaguGeorgiana23@users.noreply.github.com>
@NeaguGeorgiana23 NeaguGeorgiana23 merged commit 0e7afa6 into main Jan 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement OpenFeature Global API

3 participants