-
Notifications
You must be signed in to change notification settings - Fork 162
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 IServiceCollection extension methods to enable Steeltoe #1123
Comments
Hi @eerhardt, Thanks for the note, I really appreciate the proactivity here. We do already have many extensions for |
Thanks, @TimHess. Also check out a proposal I just opened to add an abstraction for these new application builders in .NET 8: Looking at the above extension method, it would probably need an abstraction that is being proposed. The extension method is using a lot of things on IHostBuilder:
|
@eerhardt We've completed this work in #1317. Our chosen strategy is detailed below.
Here's an example. We offer extension methods on the various host builders, which all send their logic through the wrapper to call existing Steeltoe extension methods on public static IHostBuilder AddEnvironmentActuator(this IHostBuilder builder)
{
HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder);
InternalAddEnvironmentActuator(wrapper);
return builder;
}
public static IWebHostBuilder AddEnvironmentActuator(this IWebHostBuilder builder)
{
HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder);
InternalAddEnvironmentActuator(wrapper);
return builder;
}
public static IHostApplicationBuilder AddEnvironmentActuator(this IHostApplicationBuilder builder)
{
HostBuilderWrapper wrapper = HostBuilderWrapper.Wrap(builder);
InternalAddEnvironmentActuator(wrapper);
return builder;
}
private static void InternalAddEnvironmentActuator(HostBuilderWrapper wrapper)
{
wrapper.ConfigureServices(services => services.AddEnvironmentActuator());
wrapper.ConfigureServices(services => services.ActivateActuatorEndpoints());
wrapper.ConfigureWebHost(webHostBuilder => webHostBuilder.AddManagementPort());
} |
Is your feature request related to a problem? Please describe.
With dotnet/runtime#61634 (comment) and dotnet/runtime#65109, Microsoft.Extensions.Hosting added a new way of creating a hosted app that doesn't use IHostBuilder.
Along with that, in .NET 8, the "Worker" project template is getting updated to use these new APIs. See dotnet/aspnetcore#43113.
Describe the solution you'd like
We should add overloads to
HostBuilderExtensions
that accept anIServiceCollection
orHostApplicationBuilder
instead of anIHostBuilder
. This will allow consumers using the newHostApplicationBuilder
to use Steeltoe easily.Steeltoe/src/Bootstrap/src/AutoConfiguration/HostBuilderExtensions.cs
Line 61 in 9e2cb52
Additional context
See also dotnet/runtime#68580
The text was updated successfully, but these errors were encountered: