-
Notifications
You must be signed in to change notification settings - Fork 56
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 FeatureEnabled to Variant #164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This looks good to me.
I agree that the disabled variant should be deprecated. Perhaps the GetDefaultVariant method could be enhanced to take in a parameter and dynamically create the disabled variant with the new FeatureEnabled property? Then we wouldn't have to maintain two methods and two statically defined variants. Would require some additional changes in getVariantWithoutMetrics
though.
I'm not actually sure why these methods are public. I can't see any good reason why they should be. I'll make a note of investigating if we can make them private in an upcoming major version.
EDIT: Seems like we merged some adjustments to the tests. Can I ask you to resolve them when you have a free second? Thank you.
I thought about that but it would be a breaking change. After thinking about it more, what do you think about removing the I can move the new variant to not be defined in the My thinking is just that it's always easier to expose something if its needed later than to do the opposite. |
Absolutely. We'd have to bump to 5 in that case. Yeah, I think that's a good idea for now, let's keep the new stuff internal and we can always expose it later if it makes sense. |
FeatureEnabled is similar to Enabled except in the case where the feature is enabled but there are no variants defined. This follows the client specification case [1]. Fixes Unleash#159 [1] https://github.com/Unleash/client-specification/blob/c0169d7ace35db66cdf41a7b1b4e390a4a843c3b/specifications/08-variants.json#L448
fdcbc02
to
9e470b9
Compare
@FredrikOseberg thanks for the quick replies! I updated the PR with those changes and added some clarification to the existing method. |
Fantastic. Thank you! Merging this now. |
This reverts commit 170cce6.
About the changes
FeatureEnabled is similar to Enabled except in the case where the feature is enabled but there are no variants defined. This follows the client specification case [1].
[1] https://github.com/Unleash/client-specification/blob/c0169d7ace35db66cdf41a7b1b4e390a4a843c3b/specifications/08-variants.json#L448
Closes #159
Important files
api/variant.go
Discussion points
It's a bit unclear what should happen with
api.DISABLED_VARIANT
. Personally I thinkGetDefaultVariant
should be deprecated and instead users should be checkingEnabled
on the variant but I'm not sure what other SDKs are doing. I added a newGetDefaultVariantFeatureEnabled
method to return the feature-enabled default variant but it's not obvious how anyone outside of the unleash client should be using theGetDefaultVariant
method(s). There might need to be more clarification on the methods to discourage or guide usage.