-
Notifications
You must be signed in to change notification settings - Fork 111
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
Add variants for feature flags #250
Conversation
…t/FeatureManagement-Dotnet into ajusupovic/add-variants
…t/FeatureManagement-Dotnet into ajusupovic/add-variants
… between customer use and variant use
…hods and interfaces to match
|
||
string rawFeatureStatus = configurationSection[ConfigurationFields.FeatureStatus]; | ||
|
||
string parseEnumErrorString = "Invalid {0} with value '{1}' for feature '{2}'."; |
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.
const string
{ | ||
throw new FeatureManagementException( | ||
FeatureManagementError.InvalidConfigurationSetting, | ||
string.Format(parseEnumErrorString, nameof(FeatureStatus), rawFeatureStatus, configurationSection.Key)); |
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.
string.Format(parseEnumErrorString, nameof(FeatureStatus), rawFeatureStatus, configurationSection.Key)); | |
string.Format(parseEnumErrorString, ConfigurationFields.FeatureStatus, rawFeatureStatus, configurationSection.Key)); |
Name = section[ConfigurationFields.NameKeyword], | ||
ConfigurationValue = section.GetSection(ConfigurationFields.VariantDefinitionConfigurationValue), | ||
ConfigurationReference = section[ConfigurationFields.VariantDefinitionConfigurationReference], | ||
StatusOverride = section.GetValue<StatusOverride>(ConfigurationFields.VariantDefinitionStatusOverride) |
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.
Why isn't this enum handled like others?
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.
My bad, this should definitely be checked like the previous enums. I'll add a test for invalid StatusOverride
value.
Wondering if we should have a preview branch that we merge this into. |
I think a preview branch is a good idea. We'll want to merge telemetry and variants somewhere outside of main. |
Created a new preview branch from main. |
src/Microsoft.FeatureManagement/Allocation/PercentileAllocation.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.FeatureManagement/Allocation/PercentileAllocation.cs
Outdated
Show resolved
Hide resolved
private readonly IConfiguration _configuration; | ||
private readonly ConcurrentDictionary<string, FeatureDefinition> _definitions; | ||
private IDisposable _changeSubscription; | ||
private int _stale = 0; | ||
|
||
const string ParseValueErrorString = "Invalid {0} with value '{1}' for feature '{2}'."; |
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.
How come {0}
isn't in single quotes ? And shouldn't it be "Invalid settting '{0}' with value..."
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 just based the format string off of the old error message, but since we're using a variable now I understand adding the single quotes.
|
||
if (from > to) | ||
{ | ||
throw new ArgumentException($"Double {nameof(from)} cannot be larger than double {nameof(to)}."); |
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.
Both usage of "double" should be replaced with "value of"
{ | ||
if (string.IsNullOrEmpty(percentile.Variant)) | ||
{ | ||
_logger.LogWarning($"Missing variant name for {nameof(featureDefinition.Allocation.Percentile)} allocation in feature {featureDefinition.Name}"); |
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.
The way this is used it seems like it should just be hardcoded literal "percentile"
Co-authored-by: Ross Grambo <rossgrambo@microsoft.com>
…t/FeatureManagement-Dotnet into ajusupovic/add-variants
percentile.From, | ||
percentile.To, | ||
_assignerOptions.IgnoreCase, | ||
featureDefinition.Allocation.Seed)) |
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.
If seed is null, we should use feature name.
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 would ensure that flags have different seeds by default. This ensures whoever gets mapped to 1% isn't thrown into every experiment always.
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.
Although, there is an argument that Allocation might not want to default to the same % mapping that targeting uses. Because a targeting filter of 50% with an allocation of 50% means 100% of the 50% would be allocated.
So perhaps we should default to feature name, but add "allocation" at the end or something. @jimmyca15 what do you think?
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.
@rossgrambo makes sense. Although I would put any addition before the flag name since it's unchanging and acts like prefix in my eyes.
Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com>
if (string.Equals(featureFilterConfiguration.Name, "AlwaysOn", StringComparison.OrdinalIgnoreCase)) | ||
// Handle AlwaysOn and On filters | ||
if (string.Equals(featureFilterConfiguration.Name, "AlwaysOn", StringComparison.OrdinalIgnoreCase) || | ||
string.Equals(featureFilterConfiguration.Name, "On", StringComparison.OrdinalIgnoreCase)) |
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.
Should we mention that the filter name "On" is also occupied and it is a built-in filter in the document.
No description provided.