-
Notifications
You must be signed in to change notification settings - Fork 119
Description
.NET Aspire issue link
No response
Overview
OpenFeature provides standardisation across feature flag providers, allowing developers to switch between different systems without rewriting application code. As a CNCF project it would be a great addition to the Aspire toolset. More information here: https://openfeature.dev
I am planning on bringing support of OpenFeature using the OFREP protocol (https://www.nuget.org/packages/OpenFeature.Providers.Ofrep) and a container integration (flagd).
- OFREP: https://github.com/open-feature/protocol
- flagd: https://flagd.dev
The idea behind is dotnet aspire would be able to use locally the container (flagd) using OFREP as a communication method and in production, that endpoint would be overwritten by the production endpoint. Similar on how the OTEL and Aspire dashboard currently works.
Benefits
This integration would provide the .NET Aspire community with:
- Standardised Feature Management: Consistent API across different feature flag providers (flagd, goff or others that use the OFREP endpoint)
- Enhanced Development Workflows: Local development support with containerised services
- Future Flexibility: Easy migration between OFREP compatible providers
Components
CommunityToolkit.Aspire.Hosting.OpenFeature.OFREP
<- contains the OpenFeature.OFREP specific implementationCommunityToolkit.Aspire.FlagD
<- contains the container for flagd (please note, we should not restrain from using other providers that also support OFREP like GoFeatureFlag)
Usage example
AppHost
var builder = DistributedApplication.CreateBuilder(args);
var flagd = builder.AddFlagd("feature-flags")
.WithFlagConfiguration("./flags.json")
.WithOfrepPort(8016);
var api = builder.AddProject<Projects.MyApi>("api")
.WithReference(ofrep);
ServiceDefaults
builder.Services.AddOpenFeature(ofBuilder =>
{
ofBuilder
.AddHostedFeatureLifecycle()
.AddOfrepProvider() // Service url should be retrieved from the configuration
.AddHook<TraceEnricherHook>()
.AddHook<MetricsHook>();
});
Implementation
var service = sp.GetService<IFeatureClient>(); // This is injected. Just adding the service here to showcase
var isEnabled = await featureClient.GetBooleanValueAsync( "new-feature", false);
Additional context
This is my repository for demos: https://github.com/askpt/openfeature-aspire-welcome. This repository uses the flagD provider implementation but for this issue I will focus on the OFREP provider.
I am also a maintainer for OpenFeature .NET SDK and I will be more than happy to help in the implementation of this integration.
Help us help you
Yes, I'd like to be assigned to work on this item