Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Aspire component #125

Open
LeftTwixWand opened this issue Nov 29, 2024 · 1 comment
Open

Add Aspire component #125

LeftTwixWand opened this issue Nov 29, 2024 · 1 comment

Comments

@LeftTwixWand
Copy link

LeftTwixWand commented Nov 29, 2024

It would be amazing, if we can have Flagsmith Aspire component.
I can provide some help in development of this aspire component.

Why?

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);
@matthewelwell
Copy link
Contributor

Hi @LeftTwixWand, thanks for raising this and for sharing the code snippets.

I'm interested to know what this would look like without an official Flagsmith component? Is there an option to, for example, add generic components? Something like builder.AddGenericComponent(MyComponent); ?

Being completely frank here, it's not something that we have the bandwidth to develop or maintain in house, but if you want to submit a PR, or create your own repository to hold the code than of course we'd be more than happy to review / endorse it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants