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

Minimal hosting #31825

Merged
merged 25 commits into from
Apr 21, 2021
Merged

Minimal hosting #31825

merged 25 commits into from
Apr 21, 2021

Conversation

halter73
Copy link
Member

@halter73 halter73 commented Apr 15, 2021

Description

We're looking to collect feedback on our new "minimal hosting" API which we will present at BUILD. This adds quite a few types like WebApplication and WebApplicationBuilder as minimal alternative to Host and WebHost.

We are also planning to update the dotnet new empty/dotnet new web template for preview4 to use the new WebApplication type.

For this preview only, this does add temporarily a new Configuration : IConfigurationRoot, IConfigurationBuilder type to the Microsoft.AspNetCore.Builder namespace. I plan to submit a proper API proposal for to introduce this type to the Microsoft.Extensions.Configuration shortly.

Customer Impact

This is entirely new API, so the only impact is giving customers an early preview version of this new minimal hosting API to try out. It does not change any of the existing Hosts so there's no impact to existing apps.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

This change merely adds new API to an existing Microsoft.AspNetCore assembly.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A
namespace Microsoft.AspNetCore.Builder
{
    public sealed class WebApplicationBuilder
    {
        public IWebHostEnvironment Environment { get; }
        public IServiceCollection Services { get; }
        public Configuration Configuration { get; }
        public ILoggingBuilder Logging { get; }

        // Ability to configure existing web host and host
        public ConfigureWebHostBuilder WebHost { get; }
        public ConfigureHostBuilder Host { get; }

        public WebApplication Build();
    }

    public sealed class Configuration : IConfigurationRoot, IConfigurationBuilder { }

    // The .Build() methods are explicitly implemented interface method that throw NotSupportedExceptions
    public sealed class ConfigureHostBuilder : IHostBuilder { }
    public sealed class ConfigureWebHostBuilder : IWebHostBuilder { }

    public sealed class WebApplication : IHost, IApplicationBuilder, IEndpointRouteBuilder, IAsyncDisposable
    {
        // Top level properties to access common services
        public ILogger Logger { get; }
        public ICollection<string> Urls { get; }
        public IHostApplicationLifetime Lifetime { get; }
        public IServiceProvider Services { get; }
        public IConfiguration Configuration { get; }
        public IWebHostEnvironment Environment { get; }

        // Factory methods
        public static WebApplication Create(string[]? args = null);
        public static WebApplicationBuilder CreateBuilder(string[]? args = null);

        // Methods used to start the host
        public void Run(string? url = nul);
        public Task RunAsync(string? url = null);
        public Task StartAsync(CancellationToken cancellationToken = default);
        public Task StopAsync(CancellationToken cancellationToken = default);

        public ValueTask DisposeAsync();
    }
}

Addresses #30354

See https://github.com/featherhttp/framework to see the original versions of all of the newly added types.

The new Configuration type should be in Microsoft.Extensions as noted in the issue. I plan to open an API proposal to do this tomorrow. I think we'll leave it in the ASP.NET Core shared runtime temporarily for preview4.

@halter73 halter73 force-pushed the halter73/30354 branch 4 times, most recently from dd8bd1f to 15757e6 Compare April 15, 2021 04:32
@halter73
Copy link
Member Author

@Pilchie This is up for API review Monday, but we really want this in preview4. Should we try to merge this today (pending approvals ofc), or wait for API review?

@Pilchie
Copy link
Member

Pilchie commented Apr 16, 2021

We can retarget it to the Preview 4 branch and still merge on Monday after API review.

@halter73 halter73 changed the base branch from main to release/6.0-preview4 April 19, 2021 17:15
@halter73 halter73 added this to the 6.0-preview4 milestone Apr 19, 2021
@halter73 halter73 added the Servicing-consider Shiproom approval is required for the issue label Apr 19, 2021
@ghost
Copy link

ghost commented Apr 19, 2021

Hello human! Please make sure you've included the Shiproom Template in a comment or (preferably) the PR description. Also, make sure this PR is not marked as a draft and is ready-to-merge.

@BrennanConroy
Copy link
Member

FYI, working to unblock the code check with #31982

Copy link

@LadyNaggaga LadyNaggaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Let's move forward so we can get in the hands of the customers for feedback.

@halter73 halter73 added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Apr 20, 2021
@halter73
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dougbu dougbu merged commit 506f8ce into release/6.0-preview4 Apr 21, 2021
@dougbu dougbu deleted the halter73/30354 branch April 21, 2021 00:52
@amcasey amcasey added area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-runtime labels Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-minimal-hosting Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet