-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
It would be amazing, if we can have Flagsmith Aspire component.
I can provide some help in development of this aspire component.
Why?
- There are such requests from the community Propose & Evaluate New Components For Aspire dotnet/aspire#1570
- It's the easiest way to start using Flagsmith with .NET
- Improves Flagsmith adoption across community
- Adds support for automatic DI registration
How it should look like
// AppHost.Program.cs
var builder = DistributedApplication.CreateBuilder(args);
var flagsmith = builder.AddFlagsmith();
var apiService = builder.AddProject<My_WebApi>("apiservice")
.WithEnvironment(flagsmith); // Pupulates URL and EnvironmentKey// ServiceDefaults.Extensions.cs
public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
builder.AddFlagsmithClient(); // Registers FlagsmithClient into DI with URL and EnvironmentKey
}Example of configuration with database
// AppHost.Program.cs
var builder = DistributedApplication.CreateBuilder(args);
var postgresServer = builder.AddPostgres("postgresserver")
// Mount the SQL scripts directory into the container.
// Init script would create a flagsmith database, becuase Aspire doesn't create DB by default yet.
.WithContainerName("postgresserver")
.WithBindMount("../Postgres", "/docker-entrypoint-initdb.d");
var flagsmithDatabase = postgresServer.AddDatabase("flagsmithDatabase", databaseName: "flagsmithdb");
var flagsmith = builder.AddFlagsmith()
.WithReference(flagsmithDatabase) // Populates DATABASE_URL
.WaitFor(flagsmithDatabase)
var apiService = builder.AddProject<My_WebApi>("apiservice")
.WithEnvironment(flagsmith);Metadata
Metadata
Assignees
Labels
No labels