go-feature-flag icon indicating copy to clipboard operation
go-feature-flag copied to clipboard

feat: add dynamic flagset reloading without restart

Open thomaspoignant opened this issue 1 week ago • 3 comments

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

  1. Config File Watcher: Added a file watcher using fsnotify that monitors the configuration file for changes
  2. 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
  3. Thread-Safe: All flagset operations are protected with mutex locks
  4. Comprehensive Tests: Added 9 test cases covering all scenarios

How to Test

  1. Start the relay-proxy with flagsets configured
  2. Modify the configuration file to add a new flagset
  3. The new flagset should be available without restart
  4. Try modifying an existing flagset configuration - it should be rejected
  5. 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.md and /website/docs)
  • [x] I have followed the contributing guide

thomaspoignant avatar Dec 10 '25 21:12 thomaspoignant

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

netlify[bot] avatar Dec 10 '25 21:12 netlify[bot]

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.

Files with missing lines Patch % Lines
cmd/relayproxy/config/config.go 0.00% 29 Missing :warning:
cmd/relayproxy/main.go 0.00% 24 Missing :warning:
cmd/relayproxy/service/flagset_manager.go 85.60% 14 Missing and 4 partials :warning:
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.

codecov[bot] avatar Dec 10 '25 21:12 codecov[bot]