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

[wip] fix: variant fallback usage #169

Closed
wants to merge 7 commits into from
Closed

Conversation

thomasheartman
Copy link
Contributor

@thomasheartman thomasheartman commented Dec 18, 2023

This PR fixes a bug in how we use fallback variants in this SDK.

The fallback should be used when there is no flag, when the flag doesn't have any variants, and if the flag has variants, but is disabled. However, prior to this, it was only used if the flag didn't exist.

It addresses the issues in and closes #160.

Discussion points

Overriding FeatureEnabled

Comparing this to the Node SDK, I noticed one thing that we don't seem to do: setting the FeatureEnabled property based on the flag's enabled state.

Because the fallback you pass in also has FeatureEnabled as a property, you can in theory override this. However, that means you can get into situations where the flag is actually enabled, but the variant says FeatureEnabled is false because that's what the fallback says. That seems incorrect to me, so I've added in some handling for that, but I'd like to get a second opinion on it.

Code quality

This may be my first time writing Go, so it's very possible that I've missed some idioms or similar. Please feel free to correct as many things as you want.

@thomasheartman
Copy link
Contributor Author

closing in favor of #171

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.

WithVariantFallback and WithVariantFallbackFunc are called when feature isn't found
1 participant