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: Set Unleash changed flags on change event. #724

Closed
wants to merge 1 commit into from
Closed

feat: Set Unleash changed flags on change event. #724

wants to merge 1 commit into from

Conversation

RafeArnold
Copy link

This PR

  • adds the flags that have been changed to the configuration change event for the Unleash provider.

Notes

This addition makes checking which flags have updated trivial for the end-user.

@RafeArnold RafeArnold requested a review from a team as a code owner March 18, 2024 14:24
@github-actions github-actions bot requested review from liran2000 and sighphyre March 18, 2024 14:24
@RafeArnold RafeArnold changed the title Set Unleash changed flags on change event. feat: Set Unleash changed flags on change event. Mar 18, 2024
@liran2000
Copy link
Member

hi @RafeArnold thanks for the changes, looks good.
can you please add some background, on how did you come up with this need, where is it used etc' ?

@RafeArnold
Copy link
Author

hi @RafeArnold thanks for the changes, looks good. can you please add some background, on how did you come up with this need, where is it used etc' ?

The background for this change is that being able to see which flags have actually been updated when a ProviderConfigurationChanged event is emitted is really useful at preventing unnecessary work for the receiver of the event. If a event handler is only interesting in a single flag, or a subset of flags, they can easily query the received event to see if the flags they care about have changed.

I've realised that my implementation isn't actually doing what I intended, since the ToggleResponse will contain all the feature toggles available, not just the updated ones. I guess the subscriber wrapper would require a cache of the flag keys that it could compare and update with the flags that were retrieved from the Unleash API. I'll have another crack at it and see what I can produce.

@RafeArnold
Copy link
Author

Having thought about it further, to implement my intention, I believe the subscriber wrapper would need to keep its own cache of all the flags, which feels like a huge waste of resources. If this is the case, having the event receivers perform the checks themselves seems like the best option. Feel free to close this PR, unless a better solution can be thought of.

@@ -69,7 +72,12 @@ public void toggleEvaluated(ToggleEvaluated toggleEvaluated) {
public void togglesFetched(FeatureToggleResponse toggleResponse) {
unleashSubscriber.togglesFetched(toggleResponse);
if (FeatureToggleResponse.Status.CHANGED.equals(toggleResponse.getStatus())) {
List<String> flagsChanged = new ArrayList<>();
for (FeatureToggle featureToggle : toggleResponse.getToggleCollection().getFeatures()) {
Copy link
Member

Choose a reason for hiding this comment

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

What does toggleResponse.getToggleCollection().getFeatures() contain ?
Only changed features ?
Any documentation reference from Unleash ?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, unfortunately, as per my other comment, it contains all the feature toggles available from the Unleash API, not just the changed ones, so this implementation doesn't work as intended.

@RafeArnold RafeArnold closed this Mar 18, 2024
@RafeArnold RafeArnold deleted the unleash-changed-flags branch March 18, 2024 22:13
DBlanchard88 pushed a commit to DBlanchard88/java-sdk-contrib that referenced this pull request Apr 29, 2024
…ure#724)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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