-
Notifications
You must be signed in to change notification settings - Fork 11
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: dependent features #63
Conversation
"description": "Parent does not exist", | ||
"context": {}, | ||
"toggleName": "parents.not.exist.child.enabled", | ||
"expectedResult": false |
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.
Nice, that's what I would have done too, I think this is correct. This is a big decision though. It means stale caches and/or cycling out your api key can potentially change the state of a toggle. Leaving this here for visibility in case someone has a different opinion
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.
Glad you're confirming my confirmation bias :) As you said it's up for a discussion.
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.
This is tricky. Since you can filter by tags it's technically possible to end up in a situation where the parent is not present. We'll need to implement safeguards in the SDK to warn you if this happens, but I think the behavior here is correct. If you depend on a feature toggle that you have not fetched, there is no way for us to know the evaluation result of that toggle and we can not determine that the child should be enabled.
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.
I guess this is where a feature toggle type would come in handy @kwasniew
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.
@FredrikOseberg I will try to add a warning when you try to depend on a feature that you don't have in the SDK
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.
@FredrikOseberg can you elaborate on a feature toggle type?
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.
Yes. Like we talked about in the meeting, some way to mark a toggle as dependable, we discussed the possibility of having a new feature toggle type called Dependable Toggle. If we had that, we could circumvent the filtering in the API and say that "No, we don't care that you are filtering by tags, you'll get all the dependable toggles in this project regardless".
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.
@FredrikOseberg added reference impl for warnings: Unleash/unleash-client-node@1ed0994
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.
Now I remember the dependent feature markers we talked about :) We definitely need to keep it in mind. For this spec though I think we can proceed without this concept since it will only affect the client API not this spec.
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.
Agree. This spec just surfaced the problem, so I just mentioned it here.
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.
I think it's worth including some tests that also depend on context properties, e.g. a constraint. Based on the node implementation the desired behaviour appears to be that the context is reused for the parent check as well. Worth enforcing here I think
@sighphyre addressed all your points :) |
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.
What a legend. This looks rather nice
I think others should weigh in but LGTM
"enabled": true, | ||
"dependencies": [{ | ||
"feature": "parent.with.variant", | ||
"variants": [] |
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.
This operates on returned variant results I take it? Do default-variants count as []?
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.
with variants: []
you don't check variants, only parent being enabled. It's the same as not providing variants at all.
with variants: ['disabled']
you check default variant.
This is reference impl: parent.variants.includes(this.getVariant(parent.feature, context).name)
If we think that it's a good idea to do it this way I can go ahead and add it to the spec.
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.
Ah, great! So "variants": [ ]
is the same as not including the variants property in the dependency
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.
I like it!
This pr implements dependant feature toggles. The tests are specified in the client specifications Unleash/client-specification#63
* feat: dependant toggles This pr implements dependant feature toggles. The tests are specified in the client specifications Unleash/client-specification#63
About the changes
Spec for dependent features
Data structure for dependent features:
{feature: 'parent'}
{feature: 'parent', enabled: false}
{feature: 'parent', variants: ['parentVariant', 'anotherParentVariant']}
We're deliberately choosing
feature
as a key to have an option for other types of dependencies e.g. strategiesMost of the code has the same activation strategy with a strategy variant. Enabled tests and variant tests are almost identical (only description and expected result are different).
Interesting cases:
Reference implementation passing spec tests: Unleash/unleash-client-node#520
Important files
Discussion points