Skip to content

chore: Support flag change listeners in contract tests#349

Merged
aaron-zeisler merged 4 commits intov7from
aaronz/flag-change-listener-tests
Mar 6, 2026
Merged

chore: Support flag change listeners in contract tests#349
aaron-zeisler merged 4 commits intov7from
aaronz/flag-change-listener-tests

Conversation

@aaron-zeisler
Copy link
Contributor

@aaron-zeisler aaron-zeisler commented Feb 18, 2026

This pull request is part of a larger set of PRs that implement Flag Change Listener tests for server SDKs. Here's the list of pull requests that I currently have open:


Summary

Implements test service support for the new flag change listener contract tests defined in sdk-test-harness#317. No changes to the SDK itself — only the test service (testservice/) is modified.

For context on how the test harness drives these tests and what the full test matrix covers, see the sdk-test-harness PR description.

What this PR does

Adds type definitions (testservice/servicedef/) for the three new commands and the ListenerNotification callback payload, plus the flag-change-listeners capability constant.

Implements a listenerRegistry (testservice/flag_change_listener.go) that manages all active listener subscriptions for an SDK client entity. Each registration spawns a goroutine that consumes events from the Go SDK's FlagTracker channel and POSTs a ListenerNotification JSON payload to the callback URI provided by the test harness. The registry handles:

  • General flag change listeners — subscribes via FlagTracker.AddFlagChangeListener(), with optional key filtering when the test registers for a specific flag
  • Flag value change listeners — subscribes via FlagTracker.AddFlagValueChangeListener(), which handles context-specific evaluation and old/new value tracking internally
  • Unregistration — cancels the listener goroutine via context cancellation and removes the SDK subscription
  • CleanupcloseAll() is called when the SDK client entity shuts down, ensuring no orphaned goroutines

Advertises the capability by adding flag-change-listeners to the test service's capabilities list. All 8 contract tests pass.


Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.


Note

Medium Risk
Adds new goroutine-based listener registrations that POST callbacks on flag updates; main risk is concurrency/lifecycle management causing leaks or flaky test behavior if listeners aren’t cleaned up correctly.

Overview
Adds contract-test support for flag change listeners in the Go testservice by introducing new service commands to register/unregister listeners and a callback payload (ListenerNotification).

Implements a per-client listenerRegistry that subscribes to the SDK FlagTracker for either any flag config change or value changes for a specific flag+context, forwards events to the harness via HTTP POST, and ensures listeners are cancelled on unregister and when the client entity closes. The service now advertises flag-change-listeners and flag-value-change-listeners capabilities.

Written by Cursor Bugbot for commit cbb3c53. This will update automatically on new commits. Configure here.

@aaron-zeisler aaron-zeisler force-pushed the aaronz/flag-change-listener-tests branch 3 times, most recently from 06224bc to 6f3b218 Compare February 24, 2026 16:55
@aaron-zeisler aaron-zeisler changed the title feat: Implement flag change listener tests in the Go Server SDK feat: Implement flag change listener tests in the Go server SDK Feb 24, 2026
@aaron-zeisler aaron-zeisler changed the title feat: Implement flag change listener tests in the Go server SDK feat(contrcat-tests): Implement flag change listener tests in the Go server SDK Feb 24, 2026
@aaron-zeisler aaron-zeisler changed the title feat(contrcat-tests): Implement flag change listener tests in the Go server SDK feat(contract-tests): Implement flag change listener tests in the Go server SDK Feb 24, 2026
@aaron-zeisler aaron-zeisler marked this pull request as ready for review February 24, 2026 23:57
@aaron-zeisler aaron-zeisler requested a review from a team as a code owner February 24, 2026 23:57
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Copy link
Contributor

@tanderson-ld tanderson-ld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any issues, but probably makes sense to get @keelerm84 review.

@aaron-zeisler aaron-zeisler changed the title feat(contract-tests): Implement flag change listener tests in the Go server SDK test(contract-tests): Implement flag change listener tests in the Go server SDK Feb 27, 2026
@keelerm84 keelerm84 changed the title test(contract-tests): Implement flag change listener tests in the Go server SDK chore: Implement flag change listener tests in the Go server SDK Mar 3, 2026
@keelerm84 keelerm84 changed the title chore: Implement flag change listener tests in the Go server SDK chore: Support flag change listeners in contract tests Mar 3, 2026
Add command constants, parameter structs, and the ListenerNotification
payload type to support the three new flag change listener commands:
registerFlagChangeListener, registerFlagValueChangeListener, and
unregisterListener. Also adds the CapabilityFlagChangeListeners constant
to service_params.go.

No runtime behavior is introduced in this commit; these are pure type
definitions that subsequent commits will build on.
Add flag_change_listener.go with a listenerRegistry that manages
goroutine-based subscriptions to the SDK's FlagTracker channels.
Each registered listener spawns a goroutine that consumes SDK events
and POSTs a ListenerNotification JSON payload to the provided callback
URI. General flag change listeners support optional key filtering;
value change listeners include old and new values in the payload.

Wire the three new commands into SDKClientEntity.DoCommand:
registerFlagChangeListener, registerFlagValueChangeListener, and
unregisterListener. Also calls closeAll() in Close() to cancel all
listener goroutines before the SDK client shuts down.

The flag-change-listeners capability is not yet advertised, so no
test harness tests are run yet.
Add CapabilityFlagChangeListeners to the test service capabilities list.
All 8 flag change listener tests pass against the sdk-test-harness.
@aaron-zeisler aaron-zeisler force-pushed the aaronz/flag-change-listener-tests branch from ac77b18 to cbb3c53 Compare March 6, 2026 16:46
@aaron-zeisler aaron-zeisler merged commit 6cf58a3 into v7 Mar 6, 2026
44 of 46 checks passed
@aaron-zeisler aaron-zeisler deleted the aaronz/flag-change-listener-tests branch March 6, 2026 17:07
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.

3 participants