Skip to content

Conversation

@fabriziodemaria
Copy link
Contributor

@fabriziodemaria fabriziodemaria commented Jan 15, 2026

Addressing #124.

The fix might not be that simple, if we want to execute the shutting down of providers in a background threads while leaving all the APIs available at runtime. My concern here is the possible race condition or simply operational overlap of shut downs and, for example, the in-flight evaluation operations.

Any suggestion from the Rust community is appreciated here.

@gemini-code-assist
Copy link

Summary of Changes

Hello @fabriziodemaria, 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 improves the resource management within the OpenFeature API by introducing a formal shutdown mechanism for FeatureProvider implementations. It ensures that providers can gracefully release resources when they are no longer needed, either due to being replaced or during application shutdown. The changes involve extending the FeatureProvider trait, updating the ProviderRegistry to manage the shutdown lifecycle, and adding robust tests to validate this behavior, thereby enhancing the overall stability and reliability of the system.

Highlights

  • FeatureProvider Shutdown Trait: A new shutdown asynchronous method has been added to the FeatureProvider trait, allowing providers to implement graceful termination logic and resource cleanup.
  • Provider Lifecycle Management: The ProviderRegistry now ensures that a provider's shutdown method is invoked when it is replaced by a new provider (either default or named) or when the entire registry is cleared.
  • Asynchronous and Idempotent Shutdown: A FeatureProviderWrapper and ProviderEntry have been introduced to manage provider instances, ensuring that the shutdown method is called asynchronously in the background and only once per provider, using AtomicBool for state management.
  • Enhanced Test Coverage: New tokio::test cases have been added and existing ones modified to explicitly verify that provider shutdown methods are correctly invoked when a provider is swapped out and when the global API shutdown is triggered.
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

@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 shutdown mechanism for providers, which is a great addition for resource management. The implementation correctly identifies places where provider shutdown is needed.

I've found a couple of issues with the current implementation:

  1. There's a compilation error in ProviderRegistry::set_default due to incorrect lock handling.
  2. The api.shutdown() method doesn't wait for providers to complete their shutdown process. This "fire-and-forget" behavior can be surprising and lead to resource leaks if the application exits before shutdown is complete.

I've provided detailed comments with suggestions to fix these issues. The proposed changes will make the shutdown behavior more robust and predictable.

@fabriziodemaria fabriziodemaria changed the title Shutdown fix fix: Shutdown calls providers' shutdown Jan 15, 2026
@fabriziodemaria fabriziodemaria force-pushed the shutdown-fix branch 2 times, most recently from 23fa091 to 117856b Compare January 16, 2026 15:36
Signed-off-by: Fabrizio Demaria <fabrizio.f.demaria@gmail.com>
@fabriziodemaria fabriziodemaria marked this pull request as ready for review January 19, 2026 09:26
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.

1 participant