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

No possibility to run contextual filters when calling GetVariantAsync #485

Closed
zhiyuanliang-ms opened this issue Jul 26, 2024 · 3 comments
Closed
Assignees

Comments

@zhiyuanliang-ms
Copy link
Contributor

The current signature of IVariantFeatureManager.GetVariantAsync is

ValueTask<Variant> GetVariantAsync(string feature, TargetingContext context, CancellationToken cancellationToken = default);

It accepts the parameter of type TargetingContext.

For contextual feature filter:

public interface IContextualFeatureFilter<TContext> : IFeatureFilterMetadata
{
    Task<bool> EvaluateAsync(FeatureFilterEvaluationContext featureFilterContext, TContext appContext);
}

They can use any type of context for evaluation. When calling GetVariantAsync, the contextual feature filter which requires context of types othen than TargetingContext is unuseable.

We need to change the GetVariantAsync to accept parameter of ITargetingContext.

@jimmyca15
Copy link
Member

jimmyca15 commented Jul 26, 2024

We need to change the GetVariantAsync to accept parameter of ITargetingContext

I was thinking about this and it may not be so straight forward. Using an interface, ITargetingContext limits us from adding properties. Adding properties to an interface is a breaking change. Given I know that we want to do things like add claims based targeting, I think it may be problematic to take the ITargetingContext interface.

Some alternatives I'm considering it to have

interface IVariantFeatureManager
{
...

    ValueTask<Variant> GetVariantAsync(string feature, TContext appContext, CancellationToken cancellationToken = default);
}

and an extension method

ValueTask<Variant> GetVariantAsync(this IVariantFeatureManager, string feature, TargetingContext context, CancellationToken cancellationToken = default);

For syntax sugar/discovery

@zhiyuanliang-ms
Copy link
Contributor Author

Adding properties to an interface is a breaking change. Given I know that we want to do things like add claims based targeting, I think it may be problematic to take the ITargetingContext interface.

Some alternatives I'm considering it to have

interface IVariantFeatureManager
{
...
    ValueTask<Variant> GetVariantAsync(string feature, TContext appContext, CancellationToken cancellationToken = default);
}

I agree with this.

But if we add claims to TargetingContext in the future, will we also update the ITargetingContext? If yes, we cannot avoid the potential breaking change.

@jimmyca15
Copy link
Member

But if we add claims to TargetingContext in the future, will we also update the ITargetingContext? If yes, we cannot avoid the potential breaking change.

To avoid a breaking change we'll have to come up with a new interface like IClaimsTargetingContext.

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

No branches or pull requests

3 participants