|
| 1 | +// Copyright (c) Microsoft Corporation. |
| 2 | +// Licensed under the MIT license. |
| 3 | +// |
| 4 | +using System.Threading.Tasks; |
| 5 | +using System.Threading; |
| 6 | + |
| 7 | +namespace Microsoft.FeatureManagement |
| 8 | +{ |
| 9 | + public interface IVariantFeatureManager |
| 10 | + { |
| 11 | + /// <summary> |
| 12 | + /// Checks whether a given feature is enabled. |
| 13 | + /// </summary> |
| 14 | + /// <param name="feature">The name of the feature to check.</param> |
| 15 | + /// <param name="cancellationToken">The cancellation token to cancel the operation.</param> |
| 16 | + /// <returns>True if the feature is enabled, otherwise false.</returns> |
| 17 | + Task<bool> IsEnabledAsync(string feature, CancellationToken cancellationToken); |
| 18 | + |
| 19 | + /// <summary> |
| 20 | + /// Checks whether a given feature is enabled. |
| 21 | + /// </summary> |
| 22 | + /// <param name="feature">The name of the feature to check.</param> |
| 23 | + /// <param name="context">A context providing information that can be used to evaluate whether a feature should be on or off.</param> |
| 24 | + /// <param name="cancellationToken">The cancellation token to cancel the operation.</param> |
| 25 | + /// <returns>True if the feature is enabled, otherwise false.</returns> |
| 26 | + Task<bool> IsEnabledAsync<TContext>(string feature, TContext context, CancellationToken cancellationToken); |
| 27 | + |
| 28 | + /// <summary> |
| 29 | + /// Gets the assigned variant for a specfic feature. |
| 30 | + /// </summary> |
| 31 | + /// <param name="feature">The name of the feature from which the variant will be assigned.</param> |
| 32 | + /// <param name="cancellationToken">The cancellation token to cancel the operation.</param> |
| 33 | + /// <returns>A variant assigned to the user based on the feature's allocation logic.</returns> |
| 34 | + ValueTask<Variant> GetVariantAsync(string feature, CancellationToken cancellationToken); |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// Gets the assigned variant for a specfic feature. |
| 38 | + /// </summary> |
| 39 | + /// <param name="feature">The name of the feature from which the variant will be assigned.</param> |
| 40 | + /// <param name="context">A context providing information that can be used to evaluate which variant the user will be assigned.</param> |
| 41 | + /// <param name="cancellationToken">The cancellation token to cancel the operation.</param> |
| 42 | + /// <returns>A variant assigned to the user based on the feature's allocation logic.</returns> |
| 43 | + ValueTask<Variant> GetVariantAsync<TContext>(string feature, TContext context, CancellationToken cancellationToken); |
| 44 | + } |
| 45 | +} |
0 commit comments