Introducing:ReallySimpleFeatureToggle

Introducing:ReallySimpleFeatureToggle

Monday 3 March 2014

I’ve just open sourced a new NuGet package that’ll help you prefer feature toggles over feature branches.

It’s derived from some battle-tested code used across several systems over the last couple of years and should help you trivially introduce feature toggles into your codebase.

The super happy path looks a little like this:

PM> Install-Package ReallySimpleFeatureToggle

Consider this configuration:

   
<?xml version="1.0" encoding="utf-8" ?>
  <configuration>
    <configsections>
      <section name="features" type="ReallySimpleFeatureToggle.Configuration.AppConfigProvider.FeatureConfigurationSection, ReallySimpleFeatureToggle" />
    </configsections>
&lt;features&gt;
  &lt;add name="EnabledFeature" state="Enabled" /&gt;
  &lt;add name="DisabledFeature" state="Disabled" /&gt;
  &lt;add name="EnabledFor50Percent" state="EnabledForPercentage" randompercentageenabled="50" /&gt;
&lt;/features&gt;

</configuration>

With this usage example:

    var config = ReallySimpleFeature.Toggles.GetFeatureConfiguration();
if (config.IsAvailable(FeaturesEnum.EnabledFeature))
{
    Console.WriteLine("This feature is clearly enabled");
}

if (config.IsAvailable(FeaturesEnum.DisabledFeature))
{
    Console.WriteLine("You'll never see this.");
}

const int maxTries = 50000;
var wasTrue = 0;
for (var i = 0; i != maxTries; i++)
{
    var recalculatedConfiguration = ReallySimpleFeature.Toggles.GetFeatureConfiguration();
    if (recalculatedConfiguration.IsAvailable(FeaturesEnum.EnabledFor50Percent))
    {
        wasTrue++;
    }
}

Console.WriteLine("Enabled for 50% was enabled: " + wasTrue + " times out of " + maxTries + " - Approx Percent: " + (100 * (maxTries - wasTrue) / maxTries));<br>

The barrier to entry is really low, and there’s a bunch of extensibility points so you can store your feature configuration in a central location, or add overrides into the configuration pipeline. Hopefully this’ll help you ship your code more often, with a little less fear.

Sold! Give it to me!

Get the source on GitHub: https://github.com/davidwhitney/ReallySimpleFeatureToggle
The package from NuGet: https://www.nuget.org/packages/ReallySimpleFeatureToggle 
Via the package management console: Install-Package ReallySimpleFeatureToggle

Read the documentation here: https://github.com/davidwhitney/ReallySimpleFeatureToggle/blob/master/README.md