Git Product home page Git Product logo

Comments (4)

leonids2005 avatar leonids2005 commented on May 17, 2024

Looks like this is by design :(. Not perfect imo.

Here is the code

    public async Task<bool> IsEnabledAsync<TContext>(string feature, TContext context)
    {
        //
        // First, check local cache
        if (_flagCache.ContainsKey(feature))
        {
            return _flagCache[feature];
        }

        bool enabled = await _featureManager.IsEnabledAsync(feature, context).ConfigureAwait(false);

        _flagCache[feature] = enabled;

        return enabled;
    }

from featuremanagement-dotnet.

jimmyca15 avatar jimmyca15 commented on May 17, 2024

@PiotrJustyna

The IFeatureManagerSnapshot is purposefully naïve when it comes to feature contexts. We would need a way to check for equality between contexts to be able to do anything further, and this would've required every context to implement an interface that we provide. This is not always possible so we decided not to impose this limitation. Our thoughts were that in general, if IFeatureManagerSnapshot would be useful in combination with feature contexts, then the lifetime of the feature manager snapshot would be in line with the lifetime of the feature context.

from featuremanagement-dotnet.

jimmyca15 avatar jimmyca15 commented on May 17, 2024

Another option we have is to allow Object.Equals to play the role of establishing context equality. This may solve the problem.

I do want to call out another factor that was considered. Caching an object passed in while evaluating the feature may have unintended consequences since callers might not necessarily be expecting the lifetime of the object to now be tied to the snapshot. It's something we'd want to consider if we did take the approach I just mentioned.

from featuremanagement-dotnet.

PiotrJustyna avatar PiotrJustyna commented on May 17, 2024

Thanks @jimmyca15, I guess that is fair enough. It would be great so see a bit more sophistication in how the manager operates, but I suppose I can live with it the way it is now.

I did experiment with Object.Equals as I was formulating the linked PR, but it could be costly and since the contexts are not so strictly defined, it could lead to the equality comparisons being open to interpretation by engineers. I proposed a simple solution which just requires contexts to have IDs so that they can be easily compared with no ambiguity to what is actually being compared. Not feeling too strongly about this change, but I'm sure it is going to prove useful to some. I will close the PR as I plan to close this issue as well.

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.