feat: add dynamic flagset reloading without restart
Description
This PR implements dynamic flagset reloading for the relay-proxy, allowing flagsets to be added or removed without restarting the service. The implementation follows the requirements from issue #4288:
- Add/remove flagsets without restart: Flagsets can now be dynamically added or removed by modifying the configuration file
- Reject modifications to existing flagsets: If an existing flagset configuration is modified (beyond API key changes), the entire configuration change is rejected
- Config file only: All changes are controlled through the configuration file, no API endpoints are added
Implementation Details
- Config File Watcher: Added a file watcher using
fsnotifythat monitors the configuration file for changes - ReloadFlagsets Method: New method on FlagsetManager that:
- Validates existing flagsets haven't been modified
- Adds new flagsets
- Removes deleted flagsets
- Rejects the entire change if any existing flagset is modified
- Thread-Safe: All flagset operations are protected with mutex locks
- Comprehensive Tests: Added 9 test cases covering all scenarios
How to Test
- Start the relay-proxy with flagsets configured
- Modify the configuration file to add a new flagset
- The new flagset should be available without restart
- Try modifying an existing flagset configuration - it should be rejected
- Remove a flagset from the config - it should be removed without restart
Closes issue(s)
Resolves #4288
Checklist
- [x] I have tested this code
- [x] I have added unit test to cover this code
- [ ] I have updated the documentation (
README.mdand/website/docs) - [x] I have followed the contributing guide
Deploy Preview for go-feature-flag-doc-preview canceled.
| Name | Link |
|---|---|
| Latest commit | 91c91f827f26ec916e4e616bfd7f078724cd1480 |
| Latest deploy log | https://app.netlify.com/projects/go-feature-flag-doc-preview/deploys/6939f2b75ef52b0008e1e6d1 |
Codecov Report
:x: Patch coverage is 60.11236% with 71 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 84.61%. Comparing base (57caa82) to head (91c91f8).
:warning: Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #4462 +/- ##
==========================================
- Coverage 85.33% 84.61% -0.73%
==========================================
Files 145 145
Lines 6056 6233 +177
==========================================
+ Hits 5168 5274 +106
- Misses 663 730 +67
- Partials 225 229 +4
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Quality Gate passed
Issues
4 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code