Skip to content

Commit 67b59b3

Browse files
committed
Merge branch 'feature/v3' into user/jimmyca/targetingPrecedence
2 parents 686f204 + d98f319 commit 67b59b3

21 files changed

+96
-96
lines changed

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,12 @@ Some feature filters require parameters to decide whether a feature flag should
261261
public class FeatureFilterEvaluationContext
262262
{
263263
/// <summary>
264-
/// The name of the feature being evaluated.
264+
/// The name of the feature flag being evaluated.
265265
/// </summary>
266-
public string FeatureName { get; set; }
266+
public string FeaturFlagName { get; set; }
267267

268268
/// <summary>
269-
/// The settings provided for the feature filter to use when evaluating whether the feature should be enabled.
269+
/// The settings provided for the feature filter to use when evaluating whether the feature flag should be enabled.
270270
/// </summary>
271271
public IConfiguration Parameters { get; set; }
272272
}
@@ -345,7 +345,7 @@ public void ConfigureServices(IServiceCollection services)
345345

346346
## Providing a Context For Feature Evaluation
347347

348-
In console applications there is no ambient context such as `HttpContext` that feature filters can acquire and utilize to check if a feature should be on or off. In this case, applications need to provide an object representing a context into the feature management system for use by feature filters. This is done by using `IFeatureManager.IsEnabledAsync<TContext>(string featureName, TContext appContext)`. The appContext object that is provided to the feature manager can be used by feature filters to evaluate the state of a feature flag.
348+
In console applications there is no ambient context such as `HttpContext` that feature filters can acquire and utilize to check if a feature should be on or off. In this case, applications need to provide an object representing a context into the feature management system for use by feature filters. This is done by using `IFeatureManager.IsEnabledAsync<TContext>(string featureFlagName, TContext appContext)`. The appContext object that is provided to the feature manager can be used by feature filters to evaluate the state of a feature flag.
349349

350350
``` C#
351351
MyAppContext context = new MyAppContext
@@ -516,7 +516,7 @@ One possible example of when variants may be used is in a web application when t
516516
``` C#
517517
//
518518
// Modify view based off multiple possible variants
519-
model.BackgroundUrl = featureVariantManager.GetVariantAsync<string>("HomeBackground", cancellationToken);
519+
model.BackgroundUrl = dynamicFeatureManager.GetVariantAsync<string>("HomeBackground", cancellationToken);
520520

521521
return View(model);
522522
```
@@ -549,7 +549,7 @@ An example of a dynamic feature named "ShoppingCart" is shown below.
549549
"AssignmentParameters": {
550550
"Audience": {
551551
"Users": [
552-
"Alec",
552+
"Alec"
553553
],
554554
"Groups": [
555555
]
@@ -599,13 +599,13 @@ A feature variant assigner is a component that uses contextual information withi
599599

600600
### Feature Variant Assignment
601601

602-
When requesting the value of a dynamic feature the feature manager needs to determine which variant of the feature should be used. The act of choosing which variant should be used is called assignment. A built-in method of assignment is provided that allows the variants of a dynamic features to be assigned to segments of an application's audience. This is the same [targeting](./README.md#MicrosoftTargeting-Feature-Variant-Assigner) strategy introduced by the targeting feature filter.
602+
When requesting the value of a dynamic feature, the feature manager needs to determine which variant to use. The act of choosing which of the variants to be used is called "assignment." A built-in method of assignment allows the variants of a dynamic feature to be assigned to segments of an application's audience. This is the same [targeting](./README.md#MicrosoftTargeting-Feature-Variant-Assigner) strategy used by the targeting feature filter.
603603

604-
To perform assignment the feature manager uses components known as feature variant assigners. Feature variant assigners have the job of choosing which of the variants of a dynamic feature should be used when the value of a dynamic feature is requested. Each variant of a dynamic feature declares assignment parameters so that when an assigner is invoked the assigner can tell under which conditions each variant should be selected. It is possible that an assigner is unable to choose between the list of available variants based off of their configured assignment parameters. In this case the feature manager chooses the **default variant**. The default variant is a variant that is marked explicitly as default. It is required to have a default variant when configuring a dynamic feature in order to handle the possibility that an assigner is not able to select a variant of a dynamic feature.
604+
To perform assignments, the feature manager uses components known as feature variant assigners. Feature variant assigners choose which of the variants of a dynamic feature should be assigned when a dynamic feature is requested. Each variant of a dynamic feature defines assignment parameters so that when an assigner is invoked, the assigner can tell under which conditions each variant should be selected. It is possible that an assigner is unable to choose between the list of available variants based on the configured assignment parameters. In this case, the feature manager chooses the **default variant**. The default variant is a variant that is marked explicitly as the default. It is required to have a default variant when configuring a dynamic feature in order to handle the possibility that an assigner is not able to select a variant of a dynamic feature.
605605

606606
### Custom Assignment
607607

608-
There may come a time when custom criteria is needed to decide which variant of a feature should be assigned when a feature is referenced. This is made possible by an extensibility model that allows the act of assignment to be overriden. Every feature registered in the feature management system that uses feature variants specifies what assigner should be used to choose a variant.
608+
There may come a time when custom criteria is needed to decide which variant of a feature should be assigned when a feature is referenced. This is made possible by an extensibility model that allows the act of assignment to be overridden. Every feature registered in the feature management system that uses feature variants specifies what assigner should be used to choose a variant.
609609

610610

611611
``` C#
@@ -626,13 +626,13 @@ An example implementation can be found in [this example](./examples/CustomAssign
626626

627627
### Built-In Feature Variant Assigners
628628

629-
There is a built-in feature variant assigner that uses targeting that comes with the `Microsoft.FeatureManagement` package. This assigner is not added automatically, but it can be referenced and registered as soon as the package is registered.
629+
There is a built-in feature variant assigner that uses targeting. It comes with the `Microsoft.FeatureManagement` package. This assigner is not added automatically, but it can be referenced and registered as soon as the package is registered.
630630

631631
#### Microsoft.Targeting Feature Variant Assigner
632632

633633
This feature variant assigner provides the capability to assign the variants of a dynamic feature to targeted audiences. An in-depth explanation of targeting is explained in the [targeting](./README.md#Targeting) section.
634634

635-
The assignment parameters used by the targeting feature variant assigner include an audience object which describes users, groups, and a default percentage of the user base that should receive the associated variant. Each group object that is listed in the target audience must also specify what percentage of the group's members should have receive the variant. If a user is specified in the users section directly, or if the user is in the included percentage of any of the group rollouts, or if the user falls into the default rollout percentage then that user will receive the associated variant.
635+
The assignment parameters used by the targeting feature variant assigner include an audience object which describes the user base that should receive the associated variant. The audience is made of users, groups, and a percentage of the entire user base. Each group object that is listed in the target audience is required to specify what percentage of the group's members should have receive the variant. If a user is specified in the users section directly, or if the user is in the included percentage of any of the group rollouts, or if the user falls into the default rollout percentage then that user will receive the associated variant.
636636

637637
``` JavaScript
638638
"ShoppingCart": {
@@ -645,7 +645,7 @@ The assignment parameters used by the targeting feature variant assigner include
645645
"AssignmentParameters": {
646646
"Audience": {
647647
"Users": [
648-
"Alec",
648+
"Alec"
649649
],
650650
"Groups": [
651651
{
@@ -682,7 +682,7 @@ The assignment parameters used by the targeting feature variant assigner include
682682
}
683683
```
684684

685-
Based on the configured audiences for the variants included in this feature, if the application is executing under the context of a user named `Alec` then the value of the `Big` variant will be returned. If the application is executing under the context of a user named `Susan` then the value of the `Small` variant will be returned. If a user match does not occur, then group matches are evaluated. If the application is executing under the context of a user in the group `Ring0` then the `Big` variant will be returned. If the user's group is `Ring1` instead, then the user has a 50% chance between being assigned to `Big` or `Small`. If there is not user match nor group match then the default rollout percentage is used. In this case, 80% of unmatched users will get the `Small` variant leaving the other 20% to get the `Big` variant since it is marked as the `Default`.
685+
Based on the configured audiences for the variants included in this feature, if the application is executed under the context of a user named `Alec` then the value of the `Big` variant will be returned. If the application is executing under the context of a user named `Susan` then the value of the `Small` variant will be returned. If a user match does not occur, then group matches are evaluated. If the application is executed under the context of a user in the group `Ring0` then the `Big` variant will be returned. If the user's group is `Ring1` instead, then the user has a 50% chance of being assigned to `Small`. If there is no user match nor group match, then the default rollout percentage is used. In this case, 80% of unmatched users will get the `Small` variant, leaving the other 20% to get the `Big` variant since it is marked as the `Default`.
686686

687687
Example usage of this assigner can be found in the [FeatureFlagDemo example](./examples/FeatureFlagDemo/Startup.cs#L63).
688688

@@ -697,7 +697,7 @@ services.AddFeatureManagement();
697697

698698
### Variant Resolution
699699

700-
When a variant of a dynamic feature has been chosen, the feature management system needs to resolve the configuration reference associated with that variant. A feature variant references configuration through its `ConfigurationReference` property. In the "[Configuring a Dynamic Feature](./README.md#Configuring-a-Dynamic-Feature)" section we see a dynamic feature named "ShoppingCart". The first variant of the feature, named "Big", has a configuration reference to the `ShoppingCart:Big` configuration section. The referenced section is shown below.
700+
When a variant of a dynamic feature has been chosen, the feature management system resolves the configuration reference associated with that variant. The resolution is done through the `ConfigurationReference` property. In the "[Configuring a Dynamic Feature](./README.md#Configuring-a-Dynamic-Feature)" section we see a dynamic feature named `ShoppingCart`. The first variant of the feature, is named "Big", and is being referenced in the feature variant as `ShoppingCart:Big` in the configuration reference. The referenced section is shown below.
701701

702702
``` Javascript
703703
"ShoppingCart": {
@@ -708,7 +708,7 @@ When a variant of a dynamic feature has been chosen, the feature management syst
708708
}
709709
```
710710

711-
The feature management system resolves the configuration reference and binds the resolved configuration section to the type specfied when a variant of a dynamic feature is requested. This is performed by an implementation of the `IFeatureVariantOptionsResolver`. By providing a custom implementation of `IFeatureVariantOptionsResolver`, a developer can resolve configuration references from sources other than configuration.
711+
The feature management system resolves the configuration reference and binds the resolved configuration section to the type specified when a variant of a dynamic feature is requested. This is performed by an implementation of the `IFeatureVariantOptionsResolver`. By providing a custom implementation of `IFeatureVariantOptionsResolver`, a developer can resolve configuration references from sources other than configuration.
712712

713713
## Targeting
714714

@@ -801,12 +801,12 @@ There are scenarios which require the state of a feature to remain consistent du
801801

802802
Implementing a custom feature provider enable developers to pull feature flags from sources such as a database or a feature management service. The included feature provider that is used by default pulls feature flags from .NET Core's configuration system. This allows for features to be defined in an [appsettings.json](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.1#jcp) file or in configuration providers like [Azure App Configuration](https://docs.microsoft.com/en-us/azure/azure-app-configuration/quickstart-feature-flag-aspnet-core?tabs=core2x). This behavior can be substituted to provide complete control of where feature definitions are read from.
803803

804-
To customize the loading of feature definitions, one must implement the `IFeatureFlagDefinitionProvider` interface.
804+
To customize the loading of feature flag definitions, one must implement the `IFeatureFlagDefinitionProvider` interface.
805805

806806
``` C#
807807
public interface IFeatureFlagDefinitionProvider
808808
{
809-
Task<FeatureFlagDefinition> GetFeatureFlagDefinitionAsync(string featureName, CancellationToken cancellationToken = default);
809+
Task<FeatureFlagDefinition> GetFeatureFlagDefinitionAsync(string featureflagName, CancellationToken cancellationToken = default);
810810

811811
IAsyncEnumerable<FeatureFlagDefinition> GetAllFeatureFlagDefinitionsAsync(CancellationToken cancellationToken = default);
812812
}

0 commit comments

Comments
 (0)