Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Refactoring IServerFactory #395 #445

Merged
merged 1 commit into from
Oct 30, 2015

Conversation

JunTaoLuo
Copy link
Contributor

@dnfclas
Copy link

dnfclas commented Oct 23, 2015

Hi @JunTaoLuo, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by .NET Foundation and real humans are currently evaluating your PR.

TTYL, DNFBOT;

_serverFeatures = ServerFactory.Initialize(_config);
var addresses = _serverFeatures?.Get<IServerAddressesFeature>()?.Addresses;
_server = ServerFactory.CreateServer(_config);
var addresses = _server.Features?.Get<IServerAddressesFeature>()?.Addresses;
if (addresses != null && !addresses.IsReadOnly)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you could do if (!addresses?.IsReadOnly)

@Tratcher
Copy link
Member

You're off to a good start. Next is moving IHttpContextFactory to Http.Abstractions and HttpContextFactory to Http. Then you need to update TestHost, Kestrel, and Entropy.

@JunTaoLuo JunTaoLuo force-pushed the johluo/395-iserverfactory-refactoring branch from 4a9fb84 to 9377483 Compare October 24, 2015 02:30

namespace Microsoft.AspNet.Hosting.Server
{
public interface IServer : IDisposable
Copy link
Member

Choose a reason for hiding this comment

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

Add some doc comments

@JunTaoLuo JunTaoLuo force-pushed the johluo/395-iserverfactory-refactoring branch from e0262a9 to a65f235 Compare October 25, 2015 23:51
@davidfowl
Copy link
Member

Based on what Chris said. We should update we host builder and test server to support taking and IServer or ISeverFactory. There's probably an effect on the restartability

@@ -40,60 +41,65 @@ public void Build_honors_UseStartup_with_string()
[Fact]
public async Task StartupMissing_Fallback()
{
var application = new RequestDelegate(context => { return Task.FromResult(0); });
Copy link
Member

Choose a reason for hiding this comment

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

Why the ceremony here? Shouldn't this just look like it did before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will go away once UseServer takes an IServer. This hack was added so the RequestDelegate passed into the IServer could be accessed for use in AssertResponseContains.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively, we can just make this test extend IServer and IServerFactory like HostingEngineTests.

@JunTaoLuo JunTaoLuo force-pushed the johluo/395-iserverfactory-refactoring branch from a65f235 to 5543198 Compare October 28, 2015 23:15
{
public Func<IFeatureCollection, Task> Application { get; set; }
private Action<RequestDelegate> _setAppDelegate;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing this

@JunTaoLuo
Copy link
Contributor Author

updated

/// </summary>
/// <param name="configuration">An instance of <see cref="IConfiguration"/>.</param>
/// <returns>The created server.</returns>
IServer CreateServer(IConfiguration configuration);
Copy link
Member

Choose a reason for hiding this comment

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

Create or CreateServer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the issue filed, CreateServer.

@Tratcher
Copy link
Member

:shipit: (once we get the servers updated)

@davidfowl
Copy link
Member

This looks great :shipit:

@JunTaoLuo JunTaoLuo force-pushed the johluo/395-iserverfactory-refactoring branch from 8d2388b to 3933a19 Compare October 30, 2015 20:00
@JunTaoLuo JunTaoLuo merged commit 3933a19 into dev Oct 30, 2015
@JunTaoLuo JunTaoLuo deleted the johluo/395-iserverfactory-refactoring branch November 17, 2015 23:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants