خرید بک لینک

Vote count: 0

I'm in a project where I am building a simulator of a website. I am testing how feature toggling can provide some cons that can help a team release more often that they do now.

One thing I do like to simulate is how the Canary release is working. Lets say I just finished building a new feature and I need to have it tested in production. Canary release is just to push this feature out to a small number of users.

How do you simulate this with code? I'm building the applikation with angular2 anad with typescript. Have created configurationfiles for the features that I can use.

How do you, lets say pick only 5 percents of random people that visit the site to test the specific feature? Is it all done with server configuration (ruing another build at a different server).

If any could make a code example of how I could simulate this what the application starts, I've be happy.

Have made this code myself:

var switchKey: string = localStorage.getItem('featureSwitch');

    if (this.featureSwitch != null) {
        if (switchKey == "11") {
            this.featureSwitch = 1;
            localStorage.setItem('featureSwitch', this.featureSwitch.toString());
        }
        else {
            this.featureSwitch = 5;
            localStorage.setItem('featureSwitch', this.featureSwitch.toString());
        }

    }
    else {
        if (switchKey != null) {
            if (switchKey == "11") {
                this.featureSwitch = 1;
                localStorage.setItem('featureSwitch', this.featureSwitch.toString());
            }
            else {
                this.featureSwitch = Number(switchKey) + 1;
                localStorage.setItem('featureSwitch', this.featureSwitch.toString());
            }
        }
        else {
            this.featureSwitch = 1;
            localStorage.setItem('featureSwitch', this.featureSwitch.toString());
        }

    }

This is maybe a bad example, cause I don't think it will work on a live site (on the inteet), this is only tested on a localhost server. Basically I'm saving a number from 1-11 in localstorage, where I can show a feature based on one or more numbers.

Any have some ideas how I could do this easily?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 3 خرداد 1395 ساعت: 5:23

صفحه بندی