Misc generic host pr feedback (#1222)

This commit is contained in:
Chris Ross 2017-09-21 15:09:52 -07:00 committed by GitHub
parent e53abdb2b8
commit 253be73b6f
13 changed files with 25 additions and 26 deletions

View File

@ -31,7 +31,7 @@ namespace GenericHostSample
public void RegisterDelayStartCallback(Action<object> callback, object state)
{
_startCallback = callback ?? throw new ArgumentNullException(nameof(callback));
_startState = state ?? throw new ArgumentNullException(nameof(state));
_startState = state;
Run(this);
}
@ -39,7 +39,7 @@ namespace GenericHostSample
public void RegisterStopCallback(Action<object> callback, object state)
{
_stopCallback = callback ?? throw new ArgumentNullException(nameof(callback));
_stopState = state ?? throw new ArgumentNullException(nameof(state));
_stopState = state;
}
public Task StopAsync(CancellationToken cancellationToken)

View File

@ -31,13 +31,13 @@ namespace Microsoft.AspNetCore.Hosting
/// <summary>
/// Starts listening on the configured addresses.
/// </summary>
Task StartAsync(CancellationToken cancellationToken = default(CancellationToken));
Task StartAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Attempt to gracefully stop the host.
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task StopAsync(CancellationToken cancellationToken = default(CancellationToken));
Task StopAsync(CancellationToken cancellationToken = default);
}
}

View File

@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
StartAsync().GetAwaiter().GetResult();
}
public virtual async Task StartAsync(CancellationToken cancellationToken = default(CancellationToken))
public virtual async Task StartAsync(CancellationToken cancellationToken = default)
{
HostingEventSource.Log.HostStart();
_logger = _applicationServices.GetRequiredService<ILogger<WebHost>>();
@ -282,7 +282,7 @@ namespace Microsoft.AspNetCore.Hosting.Internal
}
}
public async Task StopAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task StopAsync(CancellationToken cancellationToken = default)
{
if (_stopped)
{

View File

@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Hosting
/// </summary>
/// <param name="host">The running <see cref="IWebHost"/>.</param>
/// <param name="token">The token to trigger shutdown.</param>
public static async Task WaitForShutdownAsync(this IWebHost host, CancellationToken token = default(CancellationToken))
public static async Task WaitForShutdownAsync(this IWebHost host, CancellationToken token = default)
{
var done = new ManualResetEventSlim(false);
using (var cts = CancellationTokenSource.CreateLinkedTokenSource(token))
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Hosting
/// </summary>
/// <param name="host">The <see cref="IWebHost"/> to run.</param>
/// <param name="token">The token to trigger shutdown.</param>
public static async Task RunAsync(this IWebHost host, CancellationToken token = default(CancellationToken))
public static async Task RunAsync(this IWebHost host, CancellationToken token = default)
{
// Wait for token shutdown if it can be canceled
if (token.CanBeCanceled)

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
public static async Task<HttpResponseMessage> RetryRequest(
Func<Task<HttpResponseMessage>> retryBlock,
ILogger logger,
CancellationToken cancellationToken = default(CancellationToken),
CancellationToken cancellationToken = default,
int retryCount = 60)
{
for (var retry = 0; retry < retryCount; retry++)

View File

@ -8,7 +8,7 @@ namespace Microsoft.Extensions.Hosting
public static class HostingAbstractionsHostBuilderExtensions
{
/// <summary>
/// Start the web host and listen on the specified urls.
/// Start the host and listen on the specified urls.
/// </summary>
/// <param name="hostBuilder">The <see cref="IHostBuilder"/> to start.</param>
/// <returns>The <see cref="IHostBuilder"/>.</returns>

View File

@ -41,7 +41,7 @@ namespace Microsoft.Extensions.Hosting
}
/// <summary>
/// Runs a web application and block the calling thread until host shutdown.
/// Runs an application and block the calling thread until host shutdown.
/// </summary>
/// <param name="host">The <see cref="IHost"/> to run.</param>
public static void Run(this IHost host)
@ -50,11 +50,11 @@ namespace Microsoft.Extensions.Hosting
}
/// <summary>
/// Runs a web application and returns a Task that only completes when the token is triggered or shutdown is triggered.
/// Runs an application and returns a Task that only completes when the token is triggered or shutdown is triggered.
/// </summary>
/// <param name="host">The <see cref="IHost"/> to run.</param>
/// <param name="token">The token to trigger shutdown.</param>
public static async Task RunAsync(this IHost host, CancellationToken token = default(CancellationToken))
public static async Task RunAsync(this IHost host, CancellationToken token = default)
{
using (host)
{
@ -69,7 +69,7 @@ namespace Microsoft.Extensions.Hosting
/// </summary>
/// <param name="host">The running <see cref="IHost"/>.</param>
/// <param name="token">The token to trigger shutdown.</param>
public static async Task WaitForShutdownAsync(this IHost host, CancellationToken token = default(CancellationToken))
public static async Task WaitForShutdownAsync(this IHost host, CancellationToken token = default)
{
var applicationLifetime = host.Services.GetService<IApplicationLifetime>();
@ -88,7 +88,7 @@ namespace Microsoft.Extensions.Hosting
await waitForStop.Task;
// WebHost will use its default ShutdownTimeout if none is specified.
// Host will use its default ShutdownTimeout if none is specified.
await host.StopAsync();
}
}

View File

@ -22,13 +22,13 @@ namespace Microsoft.Extensions.Hosting
/// </summary>
/// <param name="cancellationToken">Used to abort program start.</param>
/// <returns></returns>
Task StartAsync(CancellationToken cancellationToken = default(CancellationToken));
Task StartAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Attempts to gracefully stop the program.
/// </summary>
/// <param name="cancellationToken">Used to indicate when stop should no longer be graceful.</param>
/// <returns></returns>
Task StopAsync(CancellationToken cancellationToken = default(CancellationToken));
Task StopAsync(CancellationToken cancellationToken = default);
}
}

View File

@ -1,13 +1,12 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using Microsoft.Extensions.FileProviders;
namespace Microsoft.Extensions.Hosting
{
/// <summary>
/// Provides information about the web hosting environment an application is running in.
/// Provides information about the hosting environment an application is running in.
/// </summary>
public interface IHostingEnvironment
{

View File

@ -178,7 +178,7 @@ namespace Microsoft.Extensions.Hosting
services.AddSingleton(_hostBuilderContext);
services.AddSingleton(_appConfiguration);
services.AddSingleton<IApplicationLifetime, ApplicationLifetime>();
services.AddSingleton<IHostLifetime, HostProcessLifetime>();
services.AddSingleton<IHostLifetime, ProcessLifetime>();
services.AddOptions();
services.AddLogging();

View File

@ -15,7 +15,7 @@ namespace Microsoft.Extensions.Hosting
public static class HostingHostBuilderExtensions
{
/// <summary>
/// Specify the environment to be used by the web host.
/// Specify the environment to be used by the host.
/// </summary>
/// <param name="hostBuilder">The <see cref="IHostBuilder"/> to configure.</param>
/// <param name="environment">The environment to host the application in.</param>
@ -33,7 +33,7 @@ namespace Microsoft.Extensions.Hosting
}
/// <summary>
/// Specify the content root directory to be used by the web host.
/// Specify the content root directory to be used by the host.
/// </summary>
/// <param name="hostBuilder">The <see cref="IHostBuilder"/> to configure.</param>
/// <param name="contentRoot">Path to root directory of the application.</param>
@ -125,7 +125,7 @@ namespace Microsoft.Extensions.Hosting
/// <param name="hostBuilder">The <see cref="IHostBuilder" /> to configure.</param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public static Task RunConsoleAsync(this IHostBuilder hostBuilder, CancellationToken cancellationToken = default(CancellationToken))
public static Task RunConsoleAsync(this IHostBuilder hostBuilder, CancellationToken cancellationToken = default)
{
return hostBuilder.UseConsoleLifetime().Build().RunAsync(cancellationToken);
}

View File

@ -28,7 +28,7 @@ namespace Microsoft.Extensions.Hosting.Internal
public IServiceProvider Services { get; }
public async Task StartAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task StartAsync(CancellationToken cancellationToken = default)
{
_logger.Starting();
@ -53,7 +53,7 @@ namespace Microsoft.Extensions.Hosting.Internal
_logger.Started();
}
public async Task StopAsync(CancellationToken cancellationToken = default(CancellationToken))
public async Task StopAsync(CancellationToken cancellationToken = default)
{
_logger.Stopping();

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Microsoft.Extensions.Hosting.Internal
{
public class HostProcessLifetime : IHostLifetime
public class ProcessLifetime : IHostLifetime
{
public void RegisterDelayStartCallback(Action<object> callback, object state)
{