Skip to content

kazeshini178/simple-toggle

Repository files navigation

Simple Toggle

Simple feature toggling library to work with basic on/off toggles, allowing the toggles to be stored in the service of your choice.

.NET

Toggle Sources

  • In Memory
  • AWS
    • Parameter Store
    • DynamoDB Table
    • Secrets Manager
  • Azure
    • App Configuration

Usage

  1. Install from Nuget
dotnet add package SimpleToggle.Core
  1. Update StartUp.cs
public class StartUp
{
...
    public void ConfigureServices(IServiceCollection services)
    {
       ...
       services.AddFeatureService<InMemoryToggleSource>();
       ...
    }
...
}
  1. Use IFeatureService
public class Features 
{
   public const string MYSTERY_FEATURE = "feature_indentifier";
}

public class Sample
{
    private readonly IFeatureService _featureService;

    public Sample(IFeatureService featureService)
    {
        _featureService = featureService;
    }

    public async Task<string> MysteryFeature ()
    {
        if (await _featureService.GetToggleValue(Features.MYSTERY_FEATURE))
        {
          return "Feature Enabled";
        } 
        else 
        {
          return "Feature Not Enabled";
        }
    }
}

TODO Lists

  • Add Additional AWS Sources
  • Add GPC and Azure Equivalents
  • Allow for some basic configuration options
  • Publish to Nuget
  • Added tests

Alternatives

For more feature rich alternatives, that allow A/B testing toggles, more then just on/off toggle and user targeting and tracking.