Comments (11)
@zhenlan the ask here is a bit simpler I believe. We can expose an api IEnumerable<string> GetFeatures()
. This is useful otherwise someone has to interact with IConfiguration
directly as Mariotee mentioned in his workaround. The user should not have to interact with IConfiguration to use feature manager.
Exposing GetEnabledFeatures
would be unnecessary. Rather one would just iterate over the features returned by GetFeatures()
and then evaluate whether they are enabled.
from featuremanagement-dotnet.
in Startup, can do like
using System.Linq;
//...
private IConfiguration AppSettings;
//...
//this gets the list of keys under the "FeatureManagement" object value,
//assuming following their convention
AppSettings.GetSection("FeatureManagement").GetChildren().Select((f) => f.Key);
getting list of enabled features may be more tricky if you are using the more advanced features. if you are only using the "key": boolean
method, then first filter with LINQ .Where
on bool.Parse(feature.Value) == true
and then .Select
on the keys to return the list of keys
from featuremanagement-dotnet.
I already had something similar in place actually. It just seems like something that would be convenient for FeatureManager to provide and potentially more useful than just asking for each feature one by one if you have a long list of features. Something like FeatureManager.GetAllFeatures() and FeatureManager.GetEnabledFeatures() would reduce the number of round trips on a higher latency device with questionable network quality.
from featuremanagement-dotnet.
@millicandavid the code snippet @mariotee suggested is searching configuration from the memory. It won't cause any network calls.
Just for my learning, @millicandavid, do you mind to elaborate on what are the scenarios you will want those APIs?
from featuremanagement-dotnet.
@zhenlan I understand that iterating the list of keys does not cause any network traffic, and I suppose I'm making an assumption that may not necessarily be true, but I thought my calls to _featureManager.IsEnabled(key) which are inside that iteration would be making calls to some feature management API. I suppose I should verify if that is the case or not. So if FeatureManager is only using in memory IConfiguration to resolve IsEnabled() then that's not an issue.
We front end devs were asking to just get a list of all enabled features with one call and I have this workaround so it's not a big deal. I just thought providing this within FeatureManager would make for a cleaner solution and it seemed to be within its domain. For my solution I suppose I don't need FeatureManager at all and can just use IConfiguration for everything.
from featuremanagement-dotnet.
@millicandavid thanks for sharing. The IsEnabled()
API will call feature filters (if any) as part of feature flag evaluation, so it depends on whether any of the feature filters making network calls. However, when feature filters are used, the feature flag value will depend on the context where feature filters are evaluated. This means a FeatureManager.GetEnabledFeatures()
API could potentially return different results for every request (in a web application). This is why I'm interested to learn what are the scenarios this will be useful.
from featuremanagement-dotnet.
Yes, a helper to get the list of all features makes sense. Maybe a property FeatureManager.Features
.
from featuremanagement-dotnet.
If GetEnabledFeatures() could be IEnumerable because you expect them all to be enabled. However, GetFeatures() would have to be something like IEnumerable<KeyValuePair<string, bool>> right? And yes, just having GetFeatures() would be enough if you had the feature and bool value.
from featuremanagement-dotnet.
The proposal is to not do any evaluation of the feature state with the GetFeatures()
method. It also may be clearer to call it GetFeatureNames()
. All that is needed from the feature manager is to be able to retrieve a list of registered features. If the caller wants to evaluate all their states (which requires running filters) and only use enabled features then that could be done like this:
Proposed Snippet
List<string> enabledFeatures = new List<string>();
foreach (string feature in await _featureManager.GetFeatureNames())
{
if (await _featureManager.IsEnabled(feature))
{
enabledFeatures.Add(feature);
}
}
from featuremanagement-dotnet.
Any idea when you expect to deliver this in a package?
from featuremanagement-dotnet.
@millicandavid I would estimate early March. At the moment the Azure App Configuration team is buckled down to prepare for the GA of the service. There are a few open issues that we will tackle/fix all at once and this will be included in.
from featuremanagement-dotnet.
Related Issues (20)
- Suggest to have app.UseFeatureManagement HOT 8
- Silent failure in TargetingTelemetryInitializer HOT 10
- The TargetingId should be included in the FeatureEvaluation event even if it's null/empty. HOT 5
- Targeting evaluation is CPU dependent. HOT 4
- Remove the support for variants and telemetry from the .NET feature flag schema HOT 14
- Include Targeting Information on outgoing telemetry HOT 2
- Support .NET 8 Targeting framework in Microsoft.FeatureManagement.Telemetry.ApplicationInsights.AspNetCore
- Target netstandard2.* in Microsoft.FeatureManagement.Telemetry.ApplicationInsights
- The approach to telemetry (using custom `ITelemetryPublisher`) seems overengineered and counter to modern OpenTelemetry abstractions HOT 37
- Add Default Http Targeting Context Accessor
- Consider moving `TargetingHttpContextMiddleware` to the App Insights package HOT 2
- No instance of ITargetingContextAccessor is available for variant assignment. HOT 6
- FeatureManagerSnapshot should snapshot TargetingContext as well
- EvaluationDataToApplicationInsights example
- Can't Set FeatureFilters In FeatureManager In .NET Framework Application HOT 10
- Update Package metadata
- Add a link to preview on main readme HOT 1
- Cannot use the TargetingFilter in .NET class library project HOT 3
- Nuget "Microsoft.FeatureManagement.AspNetCore" Version 3.3.0 - Multiple feature filters match the configured filter named 'Microsoft.TimeWindow' HOT 8
- Consider using `TimeProvider` using Microsoft.Bcl.TimeProvider nuget package HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from featuremanagement-dotnet.