FflagClient 0.3.2
See the version list below for details.
dotnet add package FflagClient --version 0.3.2
NuGet\Install-Package FflagClient -Version 0.3.2
<PackageReference Include="FflagClient" Version="0.3.2" />
paket add FflagClient --version 0.3.2
#r "nuget: FflagClient, 0.3.2"
// Install FflagClient as a Cake Addin #addin nuget:?package=FflagClient&version=0.3.2 // Install FflagClient as a Cake Tool #tool nuget:?package=FflagClient&version=0.3.2
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
- Install and register the package
dotnet add package FflagClient
var fflagUri = new Uri("http://localhost:9090");
builder.Services.AddFflagClient(fflagUri, options =>
{
options.UpdateIntervalInSeconds = 20; // default is 60 seconds
options.WatchedGroups.Add("this-app-name"); // at least one watched group is required
});
- Inject IFlagEvaluator into a constructor or a handler
IFlagEvaluator flagEvaluator
- 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. 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 | Versions 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. |
-
net8.0
- Google.Protobuf (>= 3.28.2)
- Grpc.AspNetCore.Server.ClientFactory (>= 2.66.0)
- Grpc.Net.Client (>= 2.66.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Standart.Hash.xxHash (>= 4.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.