Giter Club home page Giter Club logo

Comments (11)

jimmyca15 avatar jimmyca15 commented on July 27, 2024 1

@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.

mariotee avatar mariotee commented on July 27, 2024

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.

millicandavid avatar millicandavid commented on July 27, 2024

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.

zhenlan avatar zhenlan commented on July 27, 2024

@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.

millicandavid avatar millicandavid commented on July 27, 2024

@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.

zhenlan avatar zhenlan commented on July 27, 2024

@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.

zhenlan avatar zhenlan commented on July 27, 2024

Yes, a helper to get the list of all features makes sense. Maybe a property FeatureManager.Features.

from featuremanagement-dotnet.

millicandavid avatar millicandavid commented on July 27, 2024

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.

jimmyca15 avatar jimmyca15 commented on July 27, 2024

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.

millicandavid avatar millicandavid commented on July 27, 2024

Any idea when you expect to deliver this in a package?

from featuremanagement-dotnet.

jimmyca15 avatar jimmyca15 commented on July 27, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.