-
Notifications
You must be signed in to change notification settings - Fork 10
Implement shutdown functionality for API layer with complete state reset #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: josecolella <[email protected]>
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.
|
@copilot Check out https://openfeature.dev/blog/spec-0.6.0/#initialization-and-shutdown for spec information |
@copilot Here is the full spec documentation: https://openfeature.dev/specification/sections/flag-evaluation |
Co-authored-by: josecolella <[email protected]>
shutdown
to be invoked from API layer
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #195 +/- ##
=======================================
Coverage 99.55% 99.56%
=======================================
Files 16 16
Lines 226 231 +5
=======================================
+ Hits 225 230 +5
Misses 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Based on OpenFeature specification review, the shutdown method now: - Calls shutdown on all registered providers - Clears all providers from configuration - Resets SDK to initial state for proper cleanup Updated tests to verify providers are properly cleared after shutdown. Updated documentation to reflect complete shutdown behavior. Co-authored-by: josecolella <[email protected]>
Thanks for pointing me to the OpenFeature specification! I reviewed the shutdown requirements and improved the implementation. The shutdown method now properly clears all providers after shutting them down, resetting the SDK to its initial state as expected by the spec. Key improvements in commit 161aa73:
The implementation now fully complies with the OpenFeature specification for shutdown functionality.
I reviewed the specification documentation and updated the shutdown implementation accordingly. The shutdown method now properly follows the OpenFeature spec by clearing all providers and resetting the SDK state after shutdown, rather than just calling shutdown on the providers. Changes made in commit 161aa73:
|
This PR implements the ability to invoke
shutdown
from the API layer to gracefully clean up all registered providers during application shutdown.Overview
The OpenFeature specification requires a shutdown mechanism to allow applications to properly clean up resources when terminating. Previously, the Ruby SDK only supported shutdown when switching providers individually, but lacked a global shutdown capability accessible from the API layer.
Implementation
Core Changes
Configuration shutdown method: Added a
shutdown
method to theConfiguration
class that iterates through all registered providers (both default and domain-specific) and calls theirshutdown
methods if available.API layer exposure: Extended the
API
class to delegate the shutdown method from configuration, making it accessible at the API level.Thread-safe operation: Leverages the existing
@provider_mutex
to ensure shutdown operations are thread-safe.Complete state reset: The shutdown method now properly clears all providers and resets the SDK to its initial state after shutdown.
Graceful error handling: The implementation safely handles providers that don't implement a shutdown method without raising errors.
Usage
Shutdown Behavior
When
OpenFeature::SDK.shutdown
is called, it will:shutdown
method on all registered providers that support itAfter shutdown, no providers will be available and the SDK will need to be reconfigured if you want to continue using it.
Custom Provider Implementation
For custom providers that need cleanup:
Testing
Documentation
Updated the README to:
The implementation follows existing patterns in the codebase and maintains backward compatibility while adding the requested functionality according to the OpenFeature specification.
Fixes #149.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.