-
-
Notifications
You must be signed in to change notification settings - Fork 659
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
Support feature options (strings and json) or complex conditions in getVariant #1550
Comments
Hey, @amit-100ms 🙋🏼 Thanks for making the feature request and sorry it took so long to get back to you 🙇🏼 As mentioned in Slack, I think this is a very interesting and potentially very useful feature, so I'm glad you've recorded it! It's not something we can get done in Q2, but we've recorded the issue and will consider planning it for Q3 this year. That said, if it's something you think you might want to create and contribute to Unleash, then let me know! In that case, we can loop in more of the team and discuss what the right approach would be |
We are thinking also in such directions about to return strings under special conditions instead of only true/false With whom we can discuss that ? At the moment i am thinking about a custom Strategie for that, but i am not sure if it would be good to have in unleash placed. One use case: Then we will configure on unleash a list of the javaclass first part of the name and the global current log level which should be used for the application. The unleash entry then would be a list of "nondefault" loglevels like: "de.tm.however.the.class.name.begins:TRACE" When the request now tells as current classname in the code "de.tm.however.the.class.name.begins.MOREDEEPER" and the global log level of the application is "INFO", unleash would return "TRACE" The logic should be coded in the custom strategy, so that the usage in the application code is really simple like for normal toggles. This we would check everywhere where we do logging and would take the output of unleash check als log level. And boom, we would have a possibility at runtime to configure the loglevels of the application. If no ":" is in the list entry, then only "DEBUG" would be configured and the whole application would be switched to DEBUG logging without restarting. This really would be an enterprise ready solution where we can configure also big applications in this way to change at runtime loglevel for all or parts of the application. Stupid approach or have i understood the topic wrong ? |
Hey, @telekom-digioss 👋🏼 Thanks for the input! There is actually a way to return a specific string when a toggle is enabled: you can use a feature with a single variant. It's not particularly intuitive, but it does work. That way you could do something like: const extraData = unleash.getVariant('toggleName', context).payload.value Addressing your actual use case, let's see if this checks out:
You can use variants to achieve that! If so, you could achieve that as follows:
There are some limitations with this setup, most notably that variant overrides currently only support exact matches and not substring matches, but depending on your use case, it might be enough. Something like this? Updateon thinking a bit more, it's probably easier to just create a variant for each log level. Something like this: In addition to the default variant, create one variant for each log level and use the classname in the overrides. Then, when you check it in the code, you can do something like: const logLevel = unleash.getVariant('log-level').name
// logLevel would then be one of 'default', 'TRACE', 'DEBUG', etc
setLogLevel(logLevel) That's probably a much better approach. Would that work for you? |
Wanted to leave a comment here and say that we evaluated Unleash for use, but also found it inadequate as it cannot return primitive values instead of just true/false. I agree with the conversations above in that it should be a small pivot on variants. The idea is:
As you point out @thomasheartman it can basically do this already via overrides...but that does not allow for something like ordered overrides (match first of a list of sets of override rules, ex below). An additional nit is that the UI doesn't make sense in this case because a user would be purely using it for overrides. Our use case is something like "numberOfDaysForBannerDelay"...we might want to say:
In short, allow conditions to return values instead of just match on/off. Hope this helps! |
@comp615 we are adding strategy variants support this quarter. Actually this is something we're actively working on right now :) Here's the roadmap item to track: #4204 |
We'd be looking at the node/JS SDK. So exactly what you linked. I'm a hands-on person and new to all the specific terminology here, so it's a little tough for me to grok exactly what that will look like in practice and what the changes to the server and strategy functionality are, but sounds promising! I think that's exactly what I was asking about though; will it be available for the self-hosted too? |
From what I understand it it will cover the exact use case that you have. Once we have it working I will share some examples for the visual learners. And yes, from what I know it should be available for everyone. |
Here's a preview of how the new strategy variants work: 255152698-27288b01-5468-4e17-a454-c63c09a0b404.1.movThe WIP docs: https://unleash-docs-git-strategy-variants-docs-unleash-team.vercel.app/reference/feature-strategy-variants In the video I'm using tip of main for unleash-server with strategyVariant flag enabled + latest beta version of the unleash-client-node and some old version of the unleash-proxy-client-js talking to the Frontend API (which is doing the heavy lifting so the JS client doesn't need any updates). |
This feature would be really useful for us as well. Hoping its added to the go sdk soon. |
@adityameharia I don't want to overpromise anything but there's a chance we'll pick up Go SDK in the second half of August. |
@adityameharia It seems we won't need to wait until the second half of August after all. We've managed to finish the task ahead of schedule and have strategy variants support ready in v3.8.0. |
This is now supported with the strategy variants: https://docs.getunleash.io/reference/strategy-variants |
Describe the feature request
Currently we can use getVariant but it only support OR of different conditions not more complex than that. We should support more complex conditions in getVariant.
Or simply apart from feature flags unleash should support feature options returning different values on different strategies. Currently launchdarkly supports it.
Solution suggestions
The text was updated successfully, but these errors were encountered: