A GO Feature Flag client that integrates with Aspire, including health checks, logging, and telemetry.
$ dotnet add package CommunityToolkit.Aspire.GoFeatureFlagRegisters a GoFeatureFlagProvider in the DI container for connecting to a GO Feature Flag instance.
Install the Aspire GO Feature Flag Client library with NuGet:
dotnet add package CommunityToolkit.Aspire.GoFeatureFlag
In the Program.cs file of your project, call the AddGoFeatureFlagClient extension method to register a GoFeatureFlagProvider for use via the dependency injection container. The method takes a connection name parameter.
builder.AddGoFeatureFlagClient("goff");
The Aspire GO Feature Flag Client integration provides multiple options to configure the server connection based on the requirements and conventions of your project.
When using a connection string from the ConnectionStrings configuration section, you can provide the name of the connection string when calling builder.AddGoFeatureFlagClient():
builder.AddGoFeatureFlagClient("goff");
And then the connection string will be retrieved from the ConnectionStrings configuration section:
{
"ConnectionStrings": {
"goff": "Endpoint=http://localhost:19530/"
}
}
The Aspire GO Feature Flag Client integration supports Microsoft.Extensions.Configuration. It loads the GoFeatureFlagClientSettings from configuration by using the Aspire:GoFeatureFlag:Client key. Example appsettings.json that configures some of the options:
{
"Aspire": {
"GoFeatureFlag": {
"Client": {
"Endpoint": "http://localhost:19530/",
"MasterKey": "123456!@#$%"
}
}
}
}
Also you can pass the Action<GoFeatureFlagClientSettings> configureSettings delegate to set up some or all the options inline, for example to set the API key from code:
builder.AddGoFeatureFlagClient("goff", settings => settings.ProviderOptions.ApiKey = "123456!@#$%");In your AppHost project, install the CommunityToolkit.Aspire.Hosting.GoFeatureFlag library with NuGet:
dotnet add package CommunityToolkit.Aspire.Hosting.GoFeatureFlagThen, in the Program.cs file of AppHost, register a GO Feature Flag instance and consume the connection using the following methods:
var goff = builder.AddGoFeatureFlag("goff");
var myService = builder.AddProject<Projects.MyService>()
.WithReference(goff);The WithReference method configures a connection in the MyService project named goff. In the Program.cs file of MyService, the GO Feature Flag connection can be consumed using:
builder.AddGoFeatureFlagClient("goff");Then, in your service, inject GoFeatureFlagProvider and use it to interact with the GO Feature Flag API:
public class MyService(GoFeatureFlagProvider goFeatureFlagProvider)
{
// ...
}