Wookashi.FeatureSwitcher.Client.Implementation 1.2.0

dotnet add package Wookashi.FeatureSwitcher.Client.Implementation --version 1.2.0
                    
NuGet\Install-Package Wookashi.FeatureSwitcher.Client.Implementation -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Wookashi.FeatureSwitcher.Client.Implementation" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Wookashi.FeatureSwitcher.Client.Implementation" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Wookashi.FeatureSwitcher.Client.Implementation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Wookashi.FeatureSwitcher.Client.Implementation --version 1.2.0
                    
#r "nuget: Wookashi.FeatureSwitcher.Client.Implementation, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Wookashi.FeatureSwitcher.Client.Implementation@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Wookashi.FeatureSwitcher.Client.Implementation&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Wookashi.FeatureSwitcher.Client.Implementation&version=1.2.0
                    
Install as a Cake Tool

Feature Switcher Client

.NET client SDK for Feature Switcher - a distributed feature flag management system.

Installation

dotnet add package Wookashi.FeatureSwitcher.Client.Implementation

Quick Start with Dependency Injection

using Wookashi.FeatureSwitcher.Client.Implementation;

// Define your features and register with DI
var config = new FeatureSwitcherBasicClientConfiguration(
    applicationName: "MyApp",
    environmentName: "Production",
    nodeAddress: new Uri("http://localhost:8081/"));

services.AddFeatureFlags(
    config,
    new List<IFeatureStateModel>
    {
        new FeatureStateModel("DarkMode", initialState: false),
        new FeatureStateModel("NewCheckout", initialState: true),
    });

Then inject IFeatureManager in your classes:

public class MyService
{
    private readonly IFeatureManager _featureManager;

    public MyService(IFeatureManager featureManager)
    {
        _featureManager = featureManager;
    }

    public async Task DoSomethingAsync()
    {
        if (await _featureManager.IsFeatureEnabledAsync("DarkMode"))
        {
            // Feature is enabled
        }
    }
}

Manual Initialization (without DI)

using Microsoft.Extensions.DependencyInjection;
using Wookashi.FeatureSwitcher.Client.Implementation;

// 1. Set up HttpClientFactory
var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider();
var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();

// 2. Define your features
var features = new List<IFeatureStateModel>
{
    new FeatureStateModel("DarkMode", initialState: false),
    new FeatureStateModel("NewCheckout", initialState: true),
};

// 3. Create and initialize
var featureManager = new FeatureManager(
    applicationName: "MyApp",
    environmentName: "Production",
    nodeAddress: new Uri("http://localhost:8081/"),
    features: features,
    httpClientFactory: httpClientFactory);

await featureManager.RegisterFeaturesOnNodeAsync();

// 4. Check feature states
if (await featureManager.IsFeatureEnabledAsync("DarkMode"))
{
    // Feature is enabled
}

Configuration

FeatureSwitcherBasicClientConfiguration parameters:

Parameter Description
applicationName Unique identifier for your application
environmentName Environment name (e.g., Development, Production)
nodeAddress URI of the Feature Switcher Node service
allowStartWithoutNode Optional. When true, the host starts even if the Node is unreachable during startup registration. Features serve their initialState until the Node becomes reachable, and registration is retried in the background. Use it deliberately, see Resilience. Defaults to false.
requestTimeout Optional. Maximum time to wait for a single request to the Node before treating it as unreachable and falling back to the cached state. Defaults to 3 seconds.
circuitBreakDuration Optional. After the Node is found unreachable, how long to keep serving cached state without contacting the Node again. Defaults to 30 seconds.

AddFeatureFlags also takes the list of features to manage.

Feature and application names

Names are part of the Node's URLs and are shown in the Manager's feature matrix, so keep them short and URL-safe; put the explanation in the description.

Recommended (the next major version will require it): at most 50 characters, ASCII letters, digits, _, - and ., starting with a letter — for example NewCheckout, billing.retry-v2. Names that don't follow it (longer, with diacritics, spaces or other characters) keep working; the client logs one warning at startup listing them, so they can be replaced as the flags are retired.

Required (checked when the feature or the FeatureManager is created, throws ArgumentException):

Rule Why
not empty, no leading or trailing whitespace such a name produces an invalid URL
at most 100 characters the Node's database limit
none of / \ ? # % or control characters they break the Node's URLs; the flag could not be read and silently kept its cached state

The same rules apply to the application name. The limits are available as constants in NameLimits.

Describing features

A feature can carry a description and links (ticket, documentation, runbook, dashboard…). The Manager shows them when the feature is opened, so whoever switches the flag knows what it does and what happens when it is turned off. Both are optional and set in code, next to the feature definition:

new FeatureStateModel("NewCheckout", initialState: true)
{
    Description = """
        Replaces the legacy multi-step checkout with the single-page flow.

        When OFF:
        - customers are redirected to /checkout/legacy
        - carts stay compatible with both flows
        """,
    Links =
    [
        "https://jira.example.com/browse/SHOP-1423",                // just the URL
        new("Rollout plan", "https://wiki.example.com/rollout"),     // title first, then the URL
        new Uri(settings.DashboardUrl),                             // a Uri works too
    ],
},

Formatting

The description is plain text — HTML is never rendered — with a few conventions that read well both in code and in the Manager:

In code In the Manager
a blank line starts a new paragraph
lines starting with - a bullet list
other line breaks kept as they are
https://… in the text a clickable link

Use a raw string literal ("""…""") for multi-line text: C# removes the indentation, so the description looks the same in code and in the Manager. Line endings, trailing spaces and repeated blank lines are normalized, so how the file is edited doesn't matter.

A link without a title is shown as host and path (e.g. jira.example.com/browse/SHOP-1423), which is often enough; add a title when the URL says little (new("Runbook", "https://…")).

Shared flags

Details belong to the application: when several applications register the same flag, each describes its own use of it, and the Manager shows them all. They are sent with every registration, so changing or removing them in code updates the Manager on the next start. Different environments can show different details while they run different versions of the application.

Limits

Field Limit
Description 1000 characters after normalization; no control characters other than line breaks and tabs
Links 5 per feature, no duplicate URLs
Link URL absolute http or https, no credentials (user:password@), 2048 characters
Link title optional, single line, 100 characters

The limits are available as constants in FeatureDetailsLimits.

A definition that breaks a limit throws ArgumentException as soon as it is created — at application startup, or in the first test that builds your feature list — with a message saying which feature and what to fix, for example:

Feature 'NewCheckout': description is 1342 characters long, the limit is 1000. Keep the description short and move details to Links.
Link 'jira.example.com/browse/SHOP-1' must be an absolute http or https URL, e.g. "https://jira.example.com/browse/SHOP-1".

Custom feature types can provide details by implementing IFeatureDetails next to IFeatureStateModel; FeatureManager checks them against the same limits when it is created.

Details need a Node and Manager version that supports them; older Nodes accept the registration and ignore the details.

Shared Flags

Flags are shared by name on the Node. If two applications register a feature with the same name, they both reference the same global flag state. Changing the flag in the Manager from one application affects every application on that Node that registered the same flag name.

The client does not manually attach or detach applications from flags. The list passed to AddFeatureFlags or FeatureManager is the source of truth for the application-feature links maintained by the Node.

Lifecycle on the Node

Registration is append-only on the Node. New application-feature links are inserted; features missing from the payload are NOT deleted at registration time, so two services that accidentally share an applicationName cannot wipe each other's flags.

Every registration and every state read updates LastUsedAt on the application-feature link; state reads are also counted per application and day (registrations are not). The Node aggregates these updates in memory and writes them periodically (every minute by default), so usage shown in the Manager can lag slightly.

A background sweep on the Node periodically marks application-feature links whose LastUsedAt is older than the configured stale threshold (default 30 days) as PendingDeletion. Applications with no active links can also be marked as PendingDeletion. Flags in PendingDeletion:

  • Disappear from the normal /applications/{app}/features listing
  • Are auto-restored if the client reads or re-registers them
  • Can be permanently deleted by an admin through the Manager UI (with a 409-on-race guard so a stale dialog cannot delete a freshly-restored flag)

Permanent deletion removes the application-feature link. The global flag is deleted only when no other application still references it.

So from the client's perspective: flags removed from your application code disappear from that application automatically after the threshold passes without any uses. Shared flags still used by other applications keep their global state.

Resilience

A feature check never throws because the Node is unavailable: the application keeps working, and the check returns a fallback state instead of the current one set in the Manager. Which state that is depends on the situation:

Situation IsFeatureEnabledAsync returns
The Node responds the current state set in the Manager
The Node stops responding after the feature was read the last known state (kept in memory)
The application started without the Node (allowStartWithoutNode) and hasn't reached it since the initialState from code
The Node responds, but doesn't know the feature (not registered there yet) the last known state, or initialState; other features are not affected

The last known state lives in the application's memory only, so a restart while the Node is unreachable falls back to initialState.

Choosing initialState

initialState is the state used whenever the current one is not available, so choose the value that is safe if the Node cannot be reached — not the value you expect to set in the Manager:

  • a new feature being rolled out: usually false, so an outage doesn't enable an unfinished feature;
  • a kill switch that disables something in an emergency: the normal operating state, so an outage doesn't switch the feature off;
  • a feature that is on everywhere and about to be removed: true — or better, remove the flag.

Tolerating an unreachable Node at startup

By default, AddFeatureFlags registers a hosted service that calls RegisterFeaturesOnNodeAsync on startup. If the Node is unreachable, registration throws NodeUnreachableException and the host fails to start.

Set allowStartWithoutNode: true on the configuration to let the application boot anyway. The failure is logged as a warning and features serve their initialState until subsequent IsFeatureEnabledAsync calls successfully reach the Node; registration is retried in the background (after 5, 15 and 30 seconds, then every minute) until it succeeds:

var config = new FeatureSwitcherBasicClientConfiguration(
    applicationName: "MyApp",
    environmentName: "Production",
    nodeAddress: new Uri("http://localhost:8081/"),
    allowStartWithoutNode: true);

services.AddFeatureFlags(config, features);

Only transient failures are tolerated: NodeUnreachableException and RegistrationException with a server error (5xx, e.g. the Node's database is busy). EnvironmentMismatchException and other errors returned by a reachable Node still abort startup because they indicate misconfiguration.

Use it deliberately. With allowStartWithoutNode, an application started during a Node outage runs on the initialState values from code instead of the states set in the Manager, until the Node is reachable again — for every feature, not only new ones. Prefer the default when running with the wrong feature states is worse than not starting; if you enable it, choose safe initialState values (see above) and monitor the health check. Applications that create FeatureManager manually (without AddFeatureFlags) have to retry RegisterFeaturesOnNodeAsync themselves.

Health check

AddFeatureSwitcher adds an ASP.NET Core health check that reports whether feature states come from the Node:

services.AddHealthChecks().AddFeatureSwitcher();

It is Healthy when the features are registered and the latest request to the Node got a response, and Degraded otherwise, with a description saying whether the application uses initial or last known states. It sends no request of its own: it reports the outcome of the latest registration and feature check. The default status Degraded is deliberate — the application keeps working, and restarting it or taking it out of rotation because of a Node outage would only reset features to their initial states. Pass failureStatus: HealthStatus.Unhealthy if your setup requires the current states. The same information is available on FeatureManager as IsRegistered, IsNodeReachable and LastNodeContactAt.

Bounded requests and circuit breaker

Every request to the Node (registration and feature-state checks) is bounded by requestTimeout (default 3 seconds) regardless of the HttpClient's own timeout, so a Node that stops responding never blocks your application for longer than that.

If a request to the Node fails or times out, the client opens a circuit breaker for circuitBreakDuration (default 30 seconds): during that window, IsFeatureEnabledAsync returns the cached state immediately without contacting the Node again. This keeps a prolonged Node/Manager outage from costing every single feature check the full requestTimeout. Once the window elapses, the next check tries the Node again and closes the breaker on success.

var config = new FeatureSwitcherBasicClientConfiguration(
    applicationName: "MyApp",
    environmentName: "Production",
    nodeAddress: new Uri("http://localhost:8081/"),
    requestTimeout: TimeSpan.FromSeconds(2),
    circuitBreakDuration: TimeSpan.FromSeconds(15));

Documentation

For full documentation, visit the GitHub repository.

License

Licensed under the Wookashi.FeatureSwitcher Community License v1.0. See LICENSE.txt for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 123 10/14/2026
1.1.0 119 9/28/2026
1.0.1 141 8/21/2026
1.0.0 159 6/11/2026
0.8.0 139 5/21/2026
0.7.0 146 4/29/2026
0.6.2-dev 146 1/27/2026
0.6.1-dev 138 1/27/2026
0.6.0-dev 137 1/27/2026