Skip to content

Implement in_memory_provider.#61

Merged
NeaguGeorgiana23 merged 3 commits into
mainfrom
in_memory_provider
Feb 16, 2026
Merged

Implement in_memory_provider.#61
NeaguGeorgiana23 merged 3 commits into
mainfrom
in_memory_provider

Conversation

@NeaguGeorgiana23

Copy link
Copy Markdown
Contributor

This PR

This PR introduces the InMemoryProvider. This provider stores feature flags locally in memory and is primarily intended to be used for testing, allowing developers to simulate feature flag evaluations without needing an external feature management backend.

Specifically, this PR:

  • adds a Flag<T> template class to represent an in-memory feature flag, which supports variants, a default variant, a disabled state, metadata, and a custom ContextEvaluator callback for dynamic evaluation.
  • adds the InMemoryProvider class that implements the FeatureProvider interface.

Related Issues

Fixes #57

@NeaguGeorgiana23 NeaguGeorgiana23 requested review from a team as code owners February 3, 2026 11:02
@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 enhances the OpenFeature C++ SDK by introducing an InMemoryProvider. This new provider is specifically designed to facilitate local testing and development by allowing feature flags to be stored and evaluated directly within application memory, bypassing the need for an external feature management system. It includes a robust Flag<T> template class that encapsulates the various states and evaluation logic for these in-memory flags, making it easier to simulate different feature flag behaviors during development.

Highlights

  • New Flag<T> Template Class: Introduced a generic Flag<T> template class to represent in-memory feature flags, supporting variants, a default variant, a disabled state, metadata, and a custom ContextEvaluator callback for dynamic evaluation.
  • New InMemoryProvider Implementation: Implemented the InMemoryProvider class, which adheres to the FeatureProvider interface, designed primarily for local testing and simulating feature flag evaluations without an external backend.
  • Dynamic Flag Evaluation: The InMemoryProvider includes logic for evaluating flags based on the provided EvaluationContext, allowing for dynamic resolution through ContextEvaluator callbacks or falling back to default variants.
  • Flag Management Methods: Added methods to InMemoryProvider for updating the entire flag configuration (UpdateFlags) or individual flags (UpdateFlag), providing flexibility for test scenarios.
Changelog
  • openfeature/BUILD
    • Added cc_library targets for the new flag and in_memory_provider components.
  • openfeature/memory_provider/flag.h
    • Introduced the Flag<T> template class, defining the structure for in-memory feature flags with support for variants, default values, metadata, and context-based evaluators.
  • openfeature/memory_provider/in_memory_provider.cpp
    • Implemented the core logic for the InMemoryProvider, including initialization, shutdown, flag update mechanisms, and the detailed Evaluate method for resolving feature flags based on various conditions.
  • openfeature/memory_provider/in_memory_provider.h
    • Declared the InMemoryProvider class, inheriting from FeatureProvider, and defining its public interface for managing and evaluating in-memory flags.
  • test/BUILD
    • Added cc_test targets to integrate the new flag_test and in_memory_provider_test into the build system.
  • test/memory_provider/flag_test.cpp
    • Added comprehensive unit tests for the Flag<T> class, verifying its initialization, property retrieval, and the behavior of its ContextEvaluator.
  • test/memory_provider/in_memory_provider_test.cpp
    • Added comprehensive unit tests for the InMemoryProvider class, covering its lifecycle (init/shutdown), flag resolution (static, disabled, context-based), error handling, and flag update functionalities.
Activity
  • NeaguGeorgiana23 created this pull request to implement the InMemoryProvider for the OpenFeature C++ SDK.
  • The pull request addresses and fixes issue Implement In-memory provider #57, which likely requested the addition of an in-memory provider.
  • New C++ header and source files were added under openfeature/memory_provider/ to define and implement the new provider and flag structure.
  • Corresponding build rules were added to openfeature/BUILD and test/BUILD to compile the new components and their unit tests.
  • Extensive unit tests were added for both the Flag<T> class and the InMemoryProvider to ensure correctness and cover various evaluation scenarios.
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 InMemoryProvider and Flag<T> template class, providing a local, in-memory feature flag evaluation mechanism primarily for testing purposes. The implementation includes thread-safe operations for updating flags and handling provider status changes. The associated tests cover various scenarios, including flag evaluation, type mismatches, disabled flags, and context-based evaluation. Overall, the changes are well-structured and functional. I've identified a couple of areas where efficiency could be improved by avoiding unnecessary copies of data structures.

Comment thread openfeature/memory_provider/flag.h Outdated
Comment thread openfeature/memory_provider/in_memory_provider.cpp Outdated
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>

@m-olko m-olko 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.

Additionally I attach manual run of clang-tidy:

./openfeature/memory_provider/in_memory_provider.h:25:3: warning: single-argument constructors must be marked explicit to avoid unintentional implicit conversions [google-explicit-constructor]
   25 |   InMemoryProvider(std::unordered_map<std::string, std::any> flags);
      |   ^
      |   explicit 
./openfeature/memory_provider/in_memory_provider.h:27:3: warning: annotate this function with 'override' or (rarely) 'final' [modernize-use-override]
   27 |   ~InMemoryProvider() = default;
      |   ^
      |                       override
./openfeature/memory_provider/in_memory_provider.h:56:18: warning: use default member initializer for 'status_' [modernize-use-default-member-init]
   56 |   ProviderStatus status_;
      |                  ^      
      |                         {ProviderStatus::kNotReady}
./openfeature/memory_provider/in_memory_provider.cpp:76:8: warning: variable name 'it' is too short, expected at least 3 characters [readability-identifier-length]
   76 |   auto it = flags_.find(key_str);
      |        ^

Comment thread openfeature/BUILD
Comment thread openfeature/memory_provider/flag.h Outdated
Comment thread openfeature/memory_provider/in_memory_provider.h
Comment thread test/BUILD
@oxddr

oxddr commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

I defer the review to @m-olko and @alichka06

@oxddr oxddr removed their request for review February 5, 2026 16:07
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Comment thread openfeature/memory_provider/in_memory_provider.h Outdated
Comment thread test/memory_provider/in_memory_provider_test.cpp Outdated
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
@NeaguGeorgiana23 NeaguGeorgiana23 merged commit bdb2b4c into main Feb 16, 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 In-memory provider

4 participants