flagd Client integration reference
이 콘텐츠는 아직 번역되지 않았습니다.
To get started with the Aspire flagd integrations, follow the Get started with flagd integrations guide.
This article includes full details about connecting to flagd from your consuming projects using the OpenFeature SDK.
Add flagd client
Section titled “Add flagd client”To get started with the Aspire flagd client integration, install an OpenFeature provider for .NET. The most common provider for flagd is the OpenFeature.Contrib.Providers.Flagd NuGet package in the client-consuming project:
dotnet add package OpenFeature.Contrib.Providers.FlagdIn the Program.cs file of your client-consuming project, configure the OpenFeature SDK to use the flagd provider:
using OpenFeature;using OpenFeature.Contrib.Providers.Flagd;
var connectionString = builder.Configuration.GetConnectionString("flagd");
await OpenFeature.Api.Instance.SetProviderAsync( new FlagdProvider(new Uri(connectionString)));
var flagClient = OpenFeature.Api.Instance.GetClient();You can then use the flagClient to evaluate feature flags:
var welcomeBanner = await flagClient.GetBooleanValueAsync( "welcome-banner", defaultValue: false);
var backgroundColor = await flagClient.GetStringValueAsync( "background-color", defaultValue: "#000000");For more information on the OpenFeature SDK and flagd provider, see the OpenFeature .NET documentation and the flagd provider documentation.
Configuration
Section titled “Configuration”The flagd client integration uses the connection string from the ConnectionStrings configuration section. The connection string is automatically provided when you reference the flagd resource in your app host project using WithReference.
The connection string format is:
http://localhost:<port>Where <port> is the port assigned to the flagd HTTP endpoint.