Skip to content

WizX20/NOW.FeatureFlagExtensions

Repository files navigation

FeatureFlag Extensions Banner

NOW FeatureFlag Extensions is a set of extensions to support feature switching

What if you want to alter, or re-write a (part) of a service, factory, or any other class, that is registered in your application via (Microsoft) Dependency Injection. But, you want to use feature switches/toggles, without having to alter existing code in the class, and without having to restart the running application in order to test the experimental/new code? This question produced this (experimental) project and it's additional libraries.

// Register feature management and filters using Microsoft.FeatureManagement.
builder.Services.AddFeatureManagement()
.AddFeatureFlagExtensionsFeatureFilters();
builder.Services.AddFeatureFlagFeatureManagementManager();
builder.Services.AddScoped<DefaultInjectionTests.ScopedFeature.ITestServiceScoped, DefaultInjectionTests.ScopedFeature.TestServiceOneScoped>(
new FeatureFlagWrapper<DefaultInjectionTests.ScopedFeature.ITestServiceScoped>(
typeof(DefaultInjectionTests.ScopedFeature.TestServiceTwoScoped),
DefaultInjectionFlags.TestDefaultServiceScopedTwo),
new FeatureFlagWrapper<DefaultInjectionTests.ScopedFeature.ITestServiceScoped>(
typeof(DefaultInjectionTests.ScopedFeature.TestServiceThreeScoped),
DefaultInjectionFlags.TestDefaultServiceScopedThree)
);

Build Status

Branch Status
master master

NuGet Packages

Package Name .NET 7
Dependency Injection
Main
FeatureManagement Preview
Interceptors Preview
Core
DependencyInjection Preview
Managers Preview
Models Preview
Microsoft FeatureManagement
FeatureManagement Preview
FeatureManagement.Swagger Preview

Getting started

Clone the repository and run the included FeatureTestApplication, the default start-page will be the swagger documentation page, where you can play around with the registered test-features in combination with Api Versioning.

Additionally, you can visit /allservices, to display all service registrations. This endpoint uses the package Ardalis.ListStartupServices.

Features

Dependency Injection

A set of packages to enable "hot-reload" feature switching via Dependency Injection and some other, additional, extensions.

Benchmarks

Executed using v1.1.0-preview (.net 6).

Vanilla Feature Flag Usage

| Method | Mean | Error | StdDev | Rank | Gen 0 | Allocated |
|------------------------ |---------:|--------:|--------:|-----:|-------:|----------:|
| GetTestServiceScoped | 494.7 ns | 7.72 ns | 6.84 ns | 1 | 0.1001 | 840 B |
| GetTestServiceSingleton | 505.8 ns | 5.34 ns | 4.46 ns | 2 | 0.1001 | 840 B |
| GetTestServiceTransient | 507.0 ns | 1.96 ns | 1.84 ns | 2 | 0.1030 | 864 B |

FeatureFlagExtensions (Default) Usage

| Method | Mean | Error | StdDev | Rank | Gen 0 | Allocated |
|------------------------ |----------:|---------:|---------:|-----:|-------:|----------:|
| GetTestServiceScoped | 27.81 ns | 0.258 ns | 0.241 ns | 1 | - | - |
| GetTestServiceTransient | 627.39 ns | 7.377 ns | 6.160 ns | 2 | 0.1059 | 888 B |

FeatureFlagExtensions Interceptors Usage

| Method | Mean | Error | StdDev | Rank | Gen0 | Allocated |
|------------------------ |------------:|----------:|----------:|-----:|-------:|----------:|
| GetTestServiceSingleton | 24.94 ns | 0.129 ns | 0.121 ns | 1 | - | - |
| GetTestServiceScoped | 27.80 ns | 0.220 ns | 0.195 ns | 2 | - | - |
| GetTestServiceTransient | 1,790.26 ns | 24.408 ns | 19.056 ns | 3 | 0.2613 | 2192 B |

Microsoft FeatureManagement

A set of extensions and additional filters, that build on the out-of-the-box Microsoft FeatureManagement configuration.

Community

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information, see the Code of Conduct.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published