Skip to content

feat: Make the Evaluator customizable#1733

Open
chrfwow wants to merge 1 commit intoopen-feature:mainfrom
chrfwow:customize-evaluator
Open

feat: Make the Evaluator customizable#1733
chrfwow wants to merge 1 commit intoopen-feature:mainfrom
chrfwow:customize-evaluator

Conversation

@chrfwow
Copy link
Contributor

@chrfwow chrfwow commented Mar 11, 2026

This PR

Makes the evaluator configurable via the FlagdOptions

Related Issues

Fixes #1732

Signed-off-by: christian.lutnik <christian.lutnik@dynatrace.com>
@chrfwow chrfwow requested a review from a team as a code owner March 11, 2026 11:16
@chrfwow chrfwow changed the title customized evaluator feat: Make the Evaluator customizable Mar 11, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 introduces the capability to customize the Evaluator used by the flagd provider when operating in in-process mode. This enhancement allows developers to inject their own evaluation logic through FlagdOptions, providing greater flexibility and control over flag resolution. The changes ensure that if no custom evaluator is supplied, the default FlagdCore implementation is used, maintaining existing functionality while enabling advanced customization.

Highlights

  • Customizable Evaluator: The FlagdOptions now includes an Evaluator field, allowing users to provide a custom evaluation logic for in-process mode.
  • Dependency Injection: The InProcessResolver constructor has been updated to accept and utilize the Evaluator specified in FlagdOptions, falling back to FlagdCore if no custom evaluator is provided.
  • Test Coverage: New unit tests have been added to InProcessResolverTest to verify that both custom and default evaluators are correctly used and injected.
Changelog
  • providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdOptions.java
    • Imported Evaluator class.
    • Formatted a Javadoc link for better readability.
    • Added a new evaluator field with a default value, making the evaluator configurable.
  • providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/InProcessResolver.java
    • Modified the constructor to retrieve the Evaluator from FlagdOptions.
    • Implemented a fallback mechanism to use FlagdCore if no custom Evaluator is provided.
    • Updated the FlagStore initialization to use the resolved Evaluator.
    • Added a getEvaluator() method for testing purposes.
  • providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/resolver/process/InProcessResolverTest.java
    • Added necessary Mockito imports for mocking and verification.
    • Introduced usesSuppliedEvaluator test to confirm custom evaluator injection.
    • Added usesFlagdCoreEvaluatorWhenNotSupplied test to verify default evaluator behavior.
Activity
  • The pull request was created by chrfwow.
  • No human comments or reviews have been recorded yet.
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.

Copy link
Contributor

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

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 a valuable enhancement by making the Evaluator customizable in FlagdOptions. This allows users to provide their own flag evaluation logic for the in-process resolver. The implementation is clean, and the new functionality is well-covered by unit tests.

My main feedback, which is included as a specific comment, is to improve the documentation for the new evaluator option to include thread-safety requirements, as custom implementations will be called from multiple threads concurrently. This will help prevent potential race conditions for users of this new feature.

Comment on lines +238 to +241
/**
* The evaluator to use for flag evaluations. Defaults to {@code new FlagdCore()}. Only applicable in the in-process
* mode
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

It's important to document the thread-safety requirements for custom Evaluator implementations. The setFlags method is called by an internal streamer thread, while the resolve*Value methods are called by application threads. Without this information in the Javadoc, users might provide a non-thread-safe implementation, leading to potential race conditions.

Suggested change
/**
* The evaluator to use for flag evaluations. Defaults to {@code new FlagdCore()}. Only applicable in the in-process
* mode
*/
/**
* The evaluator to use for flag evaluations. Defaults to {@code new FlagdCore()}.
* Only applicable in the in-process mode.
* <p>
* <b>Note:</b> Custom implementations of {@link Evaluator} must be thread-safe, as
* methods can be called concurrently from multiple threads.
*/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a concern of a builder method

@aepfli
Copy link
Member

aepfli commented Mar 11, 2026

i think we should also add the SPI option, if a a evaluator is available, we use it via ServiceLoader, but the configuration via flagdOptions takes precedence over SPI.

@chrfwow
Copy link
Contributor Author

chrfwow commented Mar 12, 2026

@aepfli is SPI already setup for this project? I found no module.info file in the current state

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.

flagd provider: allow custom Evaluator injection in InProcessResolver

6 participants