AwsFeatureFlags 0.1.16

This package has a SemVer 2.0.0 package version: 0.1.16+87f6438ce49df61ea2fdbd73ac99e77ef1aa604a.
dotnet add package AwsFeatureFlags --version 0.1.16
NuGet\Install-Package AwsFeatureFlags -Version 0.1.16
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="AwsFeatureFlags" Version="0.1.16" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AwsFeatureFlags --version 0.1.16
#r "nuget: AwsFeatureFlags, 0.1.16"
#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.
// Install AwsFeatureFlags as a Cake Addin
#addin nuget:?package=AwsFeatureFlags&version=0.1.16

// Install AwsFeatureFlags as a Cake Tool
#tool nuget:?package=AwsFeatureFlags&version=0.1.16

AwsFeatureFlags

Wrapper around AWS AppConfig for Simple Feature Flags.
To use simply add:

var services = new ServiceCollection();
var configuration = new ConfigurationBuilder()
    .AddEnvironmentVariables()
    .AddCommandLine(args)
    .Build();

services.AddSingleton(configuration);
services.AddDefaultAWSOptions(p => p.GetService<IConfiguration>().GetAWSOptions());
services.AddFeatureFlags();

var provider = services.BuildServiceProvider();

Configuration

By default AwsFeatureFlags pulls its configuration from IConfiguration which can be configured in many ways and come from any number of sources.

Without specifying a configuration source, AwsFeatureFlags will look for a FeatureFlags section in the appsettings.json file, or other configuration source.

AwsFeatureFlags can also be configured using one of the overrides of AddFeatureFlags(), as follows:

services.AddFeatureFlags(o => myPreconfiguredOptions);

Or:

services.AddFeatureFlags(o => {
    o.ApplicationIdentifier = "myApp";
    o.EnvironmentIdentifier = "dev";
    o.ConfigurationProfileIdentifier = "default";
});

Note that you don't have to set RequiredMinimumPollIntervalInSeconds as it will default to 120 seconds (2 minutes).

Or:

services.AddFeatureFlags(p => {
    var myService = p.GetService<MyService>();
    return myService.GetOptions();
});

In all of the above cases the AddFeatureFlags() method takes care of everything that AwsFeatureFlags needs to work.

AWS Configuration

AwsFeatureFlags does use the AWSSDK.Extensions.NETCore.Setup package, and as such you will need the following somewhere in your dependency tree:

services.AddDefaultAWSOptions(p => p.GetService<IConfiguration>().GetAWSOptions());

Usage

AwsFeatureFlags provides a simple interface for checking feature flags:

  1. Simply configure as above and the IFeatureFlagService will be added to your DI tree
  2. Inject into a class you are using:
    namespace: mynamespace;
    
    public class MyClass
    {
         private readonly IFeatureFlagService _featureFlags;
    
         public MyClass(IFeatureFlagService featureFlags)
            => _featureFlags = featureFlags;
    
         public async Task Get()
         {
             var enabled = await _featureFlags.IsEnabledAsync("my_flag");
             if(!enabled) return;
    
             // do some things here
         }
    }
    

Methods

AwsFeatureFlags provides a single service IFeatureFlagService which encapsulates all the functionality that this package provides. This provides the following methods:

Signature Return Type Description
Get(string key) FeatureFlag Gets a single Feature Flag.
GetAsync(string key, CancellationToken cancellationToken = default) Task<FeatureFlag> Gets a single feature flag asynchronously.
IsEnabled(string key) bool Returns whether or not a given flag is enabled. If the flag is not found, it returns true.
IsEnabledAsync(string key, CancellationToken cancellationToken = default) Task<bool> Returns whether or not a given flag is enabled asynchronously. If the flag is not found, it returns true.
All() IEnumerable<FeatureFlag> Gets all known feature flags.
AllAsync(CancellationToken cancellationToken = default) Task<IEnumerable<FeatureFlag>> Gets all know feature flags asynchronously.

Notes

  1. The feature flags need to be defined, and setup as per the AWS documentation (here).
  2. The key used needs to exactly correspond to what has been created in AppConfig.
  3. AwsFeatureFlags will not throw an exception if a flag is not found, the default behaviour is to return true, or null if not found.
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. 
.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
0.1.16 154 11/22/2023
0.1.15 30 11/21/2023
0.1.11 37 11/21/2023
0.1.10 44 11/13/2023
0.1.9 42 11/13/2023
0.1.8 40 11/13/2023
0.1.7 40 11/13/2023
0.1.3 41 11/13/2023