GO Feature Flag Client integration reference

⭐ Community Toolkit

To get started with the Aspire GO Feature Flag integrations, follow the Get started with GO Feature Flag integrations guide.

This article includes full details about the Aspire GO Feature Flag Client integration.

Installation

To access the types and APIs for the GO Feature Flag client integration, install the 📦 CommunityToolkit.Aspire.GoFeatureFlag NuGet package in the client-consuming project:

Install the NuGet package
dotnet add package CommunityToolkit.Aspire.GoFeatureFlag

Add GO Feature Flag client

In the Program.cs file of your client-consuming 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(connectionName: "goff");

Tip

The connectionName parameter must match the name used when adding the goff resource in the AppHost project.

You can then retrieve the GoFeatureFlagProvider instance using dependency injection:

public class ExampleService(GoFeatureFlagProvider provider)
{
    // Use provider...
}

Add keyed GO Feature Flag client

There might be situations where you want to register multiple GoFeatureFlagProvider instances with different connection names. To register keyed goff clients, call the AddKeyedGoFeatureFlagClient method:

builder.AddKeyedGoFeatureFlagClient(name: "technical");
builder.AddKeyedGoFeatureFlagClient(name: "business");

Then you can retrieve the GoFeatureFlagProvider instances using dependency injection:

public class ExampleService(
    [FromKeyedServices("technical")] GoFeatureFlagProvider technicalProvider,
    [FromKeyedServices("business")] GoFeatureFlagProvider businessProvider)
{
    // Use providers...
}

Client integration health checks

The Aspire goff integration uses the configured client to perform a health check.