Skip to content
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

feat: Add config to allow surpressing notification on launch (flag cache load) #2534

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

8ma10s
Copy link

@8ma10s 8ma10s commented Oct 17, 2024

Description

This pull request introduces a new feature to disable notifications on initialization and refactors the caching mechanism to support this feature. It also includes updates to the test suite to ensure the new functionality works as expected.

Problem

  • go-feature-flag always sent notification of diff to all Notifierson ffClient initialization because it detects the difference between the initial cache (= always empty) and the flags retrieved.

Resolution

  • introduce DisableNotificationOnInit configuration key. If set to true, avoid sending the notification on cache initialization (it will still send notification when the change is detected AFTER initialization)
    • Since the behavior (should) stays the same if the new config is NOT set, it should not introduce any breaking change.

How to test

  • I've added some tests to make sure the behavior stays the same when the new config is not explicitly set. You can run go test ./...
  • Or, simply initialize ffClient should do the trick too.

Closes issue(s)

Resolve #2532

Checklist

  • I have tested this code
  • I have added unit test to cover this code
  • I have updated the documentation (README.md and /website/docs)
  • I have followed the contributing guide

Copy link

netlify bot commented Oct 17, 2024

Deploy Preview for go-feature-flag-doc-preview canceled.

Name Link
🔨 Latest commit ad3bf62
🔍 Latest deploy log https://app.netlify.com/sites/go-feature-flag-doc-preview/deploys/6711954b9fcfb6000800f62c

@8ma10s 8ma10s changed the title Skip notification on launch feat: Add config to allow surpressing notification on launch (flag cache load) Oct 17, 2024
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85.90%. Comparing base (9ce4b93) to head (fa5dda7).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
feature_flag.go 86.36% 2 Missing and 1 partial ⚠️
cmd/relayproxy/service/gofeatureflag.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2534      +/-   ##
==========================================
+ Coverage   85.84%   85.90%   +0.06%     
==========================================
  Files         100      100              
  Lines        3554     3577      +23     
==========================================
+ Hits         3051     3073      +22     
- Misses        378      379       +1     
  Partials      125      125              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This also aligns the interval with rest of the test code
@8ma10s 8ma10s marked this pull request as ready for review October 17, 2024 09:09
@8ma10s 8ma10s marked this pull request as draft October 17, 2024 22:36
Copy link

sonarcloud bot commented Oct 17, 2024

@8ma10s 8ma10s marked this pull request as ready for review October 18, 2024 08:51
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.

(change) Don't send "new flag added" notification upon ffClient initialization
2 participants