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: integrating Yggdrasil #223

Closed
wants to merge 8 commits into from
Closed

WIP: integrating Yggdrasil #223

wants to merge 8 commits into from

Conversation

gastonfournier
Copy link
Contributor

This is a WIP PR with the idea of gathering early feedback. Note that this is intended to "Work on my machine"

@@ -76,6 +76,7 @@ public ClientFeaturesResponse fetchFeatures() throws UnleashException {
FeatureCollection features =
JsonFeatureParser.fromJson(
Objects.requireNonNull(response.body()).charStream());
// TODO is this being used? Or HttpFeatureFetcher took over?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we delete OkHttpFeatureFetcher? I couldn't find valid references to it

Comment on lines 69 to 71
} catch (YggdrasilInvalidInputException e) {
LOG.error("Failed to take state", e);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sighphyre do you think this is ok?

return isEnabled(toggleName, contextProvider.getContext(), defaultSetting);
try {
UnleashContext enhancedContext = contextProvider.getContext().applyStaticFields(config);
return Optional.ofNullable(unleashEngine.isEnabled(toggleName, adapt(enhancedContext))).orElse(defaultSetting);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

UnleashEngine can return null when calling isEnabled and the SDK needs to handle this situation and provide a default value if present

Comment on lines 153 to 154
// PR-comment: constraints are no longer managed by the SDK but by Yggdrasil, so we removed the third parameter
verify(fallback).isEnabled(any(), any());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just wanted to double/triple check that it's ok to drop constraints parameters here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chriswk maybe you know, but this is a public interface we want to get rid of:

default boolean isEnabled(
Map<String, String> parameters,
UnleashContext unleashContext,
List<Constraint> constraints) {
return ConstraintUtil.validate(constraints, unleashContext)
&& isEnabled(parameters, unleashContext);

The constraints are evaluated by Yggdrasil, and I believe this is just to do the evaluation in the SDK, but no one should ever extend this, but it's possible. So, I wonder how should we move this forward, we have the opportunity to make a hard-breaking change.

Comment on lines 244 to 249
try {
VariantDef variantResponse = this.unleashEngine.getVariant(toggleName, adapt(enhancedContext));
if (variantResponse != null) {
return new FeatureEvaluationResult(variantResponse.isEnabled(),
new Variant(variantResponse.getName(), adapt(variantResponse.getPayload()), variantResponse.isEnabled()));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we always try to read variants first?

@gastonfournier gastonfournier force-pushed the yggdrasil-engine branch 3 times, most recently from 255a577 to 10387e1 Compare November 17, 2023 14:53
Copy link

stale bot commented Dec 17, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 17, 2023
@stale stale bot closed this Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant