FflagClient 0.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package FflagClient --version 0.2.1                
NuGet\Install-Package FflagClient -Version 0.2.1                
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="FflagClient" Version="0.2.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FflagClient --version 0.2.1                
#r "nuget: FflagClient, 0.2.1"                
#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 FflagClient as a Cake Addin
#addin nuget:?package=FflagClient&version=0.2.1

// Install FflagClient as a Cake Tool
#tool nuget:?package=FflagClient&version=0.2.1                

FflagClient

This is a client-side C# client for FFlag. It evaluates requests right in the process on a client instead of making an HTTP call to FFlag every time a flag is requested. The benefit of it is a huge unmatched performance (see benchmark)

How to use

  1. Add the client to the dependency container
builder.Services.AddFflagClient(new Uri("http://localhost:9090"), options =>
{
    options.UpdateIntervalInSeconds = 20; // default is 60 seconds
    options.WatchedGroups.Add("this-app-name");
});

You need to point the client to the Uri of the FFlag and specify at least one watched group.

  1. Inject IFlagEvaluator into a constructor or a handler
IFlagEvaluator flagEvaluator
  1. Call the client
flagEvaluator.GetBool(flagName); // just a flag name
flagEvaluator.GetBool(flagName, userId); // flag name and entityId
flagEvaluator.GetBool(flagName, userId, Parameters.Add(countryCode).Add(age)); // with parameters

// other methods are available. Call these depending on the type of a flag
flagEvaluator.GetDouble(...)
flagEvaluator.GetLong(...)
flagEvaluator.GetString(...)

How it works

The client has a background job that queries flag configurations from FFlag every UpdateIntervalInSeconds. The server returns flags updated since the last time. The configuration is stored in memory. FFlag can have thousands of flags defined in it, but it's rare that an app needs all of them. Usually only a subset of flags is queried from an app and the rest of the flags are meant for other apps.

To specify which flag configuration to keep in memory, provide a list of groups to which the flags should belong. A group is just a string that denotes a set of flags and is defined in FFlag UI:

alternate text is missing from this package README image

A flag can belong to multiple groups. A flag must have a group to be used in FflagClient.

A group can be a name of an app or a name of a UX flow if the flow goes through multiple services and is queried by all of them.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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.3.6 1,433 10/18/2024
0.3.5 168 10/18/2024
0.3.4 80 10/7/2024
0.3.3 78 10/7/2024
0.3.2 93 10/7/2024
0.3.1 87 10/6/2024
0.3.0 89 10/6/2024
0.2.4 86 10/5/2024
0.2.3 86 10/5/2024
0.2.2 85 10/5/2024
0.2.1 84 10/5/2024
0.2.0 92 10/4/2024