Removing dependency on Microsoft.Extensions.PlatformAbstractions
This commit is contained in:
parent
d4853f9b7c
commit
c1b21b89d5
|
|
@ -7,29 +7,20 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.AspNet.Server.Kestrel.Http;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel
|
||||
{
|
||||
public class KestrelEngine : ServiceContext, IDisposable
|
||||
{
|
||||
public KestrelEngine(ILibraryManager libraryManager, ServiceContext context)
|
||||
: this(context)
|
||||
{
|
||||
Libuv = new Libuv();
|
||||
}
|
||||
public KestrelEngine(ServiceContext context)
|
||||
: this(new Libuv(), context)
|
||||
{ }
|
||||
|
||||
// For testing
|
||||
internal KestrelEngine(Libuv uv, ServiceContext context)
|
||||
: this(context)
|
||||
: base(context)
|
||||
{
|
||||
Libuv = uv;
|
||||
}
|
||||
|
||||
private KestrelEngine(ServiceContext context)
|
||||
: base(context)
|
||||
{
|
||||
Threads = new List<KestrelThread>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ using Microsoft.AspNet.Server.Features;
|
|||
using Microsoft.AspNet.Server.Kestrel.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel
|
||||
{
|
||||
|
|
@ -20,13 +19,11 @@ namespace Microsoft.AspNet.Server.Kestrel
|
|||
/// </summary>
|
||||
public class ServerFactory : IServerFactory
|
||||
{
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IApplicationLifetime _appLifetime;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public ServerFactory(ILibraryManager libraryManager, IApplicationLifetime appLifetime, ILoggerFactory loggerFactory)
|
||||
public ServerFactory(IApplicationLifetime appLifetime, ILoggerFactory loggerFactory)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
_appLifetime = appLifetime;
|
||||
_logger = loggerFactory.CreateLogger("Microsoft.AspNet.Server.Kestrel");
|
||||
}
|
||||
|
|
@ -56,7 +53,7 @@ namespace Microsoft.AspNet.Server.Kestrel
|
|||
{
|
||||
var information = (KestrelServerInformation)serverFeatures.Get<IKestrelServerInformation>();
|
||||
var dateHeaderValueManager = new DateHeaderValueManager();
|
||||
var engine = new KestrelEngine(_libraryManager, new ServiceContext
|
||||
var engine = new KestrelEngine(new ServiceContext
|
||||
{
|
||||
AppLifetime = _appLifetime,
|
||||
Log = new KestrelTrace(_logger),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Hosting": "1.0.0-*",
|
||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-*",
|
||||
"System.Numerics.Vectors": "4.1.1-beta-*",
|
||||
"Microsoft.StandardsPolice": {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.AspNet.Server.Kestrel;
|
||||
using Microsoft.AspNet.Server.Kestrel.Filter;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -57,29 +56,6 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
|||
}
|
||||
}
|
||||
|
||||
ILibraryManager LibraryManager
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var locator = CallContextServiceLocator.Locator;
|
||||
if (locator == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var services = locator.ServiceProvider;
|
||||
if (services == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (ILibraryManager)services.GetService(typeof(ILibraryManager));
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{ return null; }
|
||||
}
|
||||
}
|
||||
|
||||
private async Task AppChunked(IFeatureCollection frame)
|
||||
{
|
||||
var request = frame.Get<IHttpRequestFeature>();
|
||||
|
|
@ -103,7 +79,7 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
|||
[MemberData(nameof(ConnectionFilterData))]
|
||||
public void EngineCanStartAndStop(ServiceContext testContext)
|
||||
{
|
||||
var engine = new KestrelEngine(LibraryManager, testContext);
|
||||
var engine = new KestrelEngine(testContext);
|
||||
engine.Start(1);
|
||||
engine.Dispose();
|
||||
}
|
||||
|
|
@ -112,7 +88,7 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
|||
[MemberData(nameof(ConnectionFilterData))]
|
||||
public void ListenerCanCreateAndDispose(ServiceContext testContext)
|
||||
{
|
||||
var engine = new KestrelEngine(LibraryManager, testContext);
|
||||
var engine = new KestrelEngine(testContext);
|
||||
engine.Start(1);
|
||||
var address = ServerAddress.FromUrl("http://localhost:54321/");
|
||||
var started = engine.CreateServer(address, App);
|
||||
|
|
@ -124,7 +100,7 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
|||
[MemberData(nameof(ConnectionFilterData))]
|
||||
public void ConnectionCanReadAndWrite(ServiceContext testContext)
|
||||
{
|
||||
var engine = new KestrelEngine(LibraryManager, testContext);
|
||||
var engine = new KestrelEngine(testContext);
|
||||
engine.Start(1);
|
||||
var address = ServerAddress.FromUrl("http://localhost:54321/");
|
||||
var started = engine.CreateServer(address, App);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System.Threading;
|
|||
using Microsoft.AspNet.Server.Kestrel;
|
||||
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Server.KestrelTests
|
||||
|
|
@ -17,29 +16,11 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
|||
private readonly IKestrelTrace _logger;
|
||||
public MultipleLoopTests()
|
||||
{
|
||||
var engine = new KestrelEngine(LibraryManager, new TestServiceContext());
|
||||
var engine = new KestrelEngine(new TestServiceContext());
|
||||
_uv = engine.Libuv;
|
||||
_logger = engine.Log;
|
||||
}
|
||||
|
||||
ILibraryManager LibraryManager
|
||||
{
|
||||
get
|
||||
{
|
||||
var locator = CallContextServiceLocator.Locator;
|
||||
if (locator == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var services = locator.ServiceProvider;
|
||||
if (services == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (ILibraryManager)services.GetService(typeof(ILibraryManager));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact(Skip = "Waiting for adding support for multi loop in libuv")]
|
||||
public void InitAndCloseServerPipe()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
|||
using Microsoft.AspNet.Server.Kestrel;
|
||||
using Microsoft.AspNet.Server.Kestrel.Infrastructure;
|
||||
using Microsoft.AspNet.Server.Kestrel.Networking;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Server.KestrelTests
|
||||
|
|
@ -23,29 +22,11 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
|||
private readonly IKestrelTrace _logger;
|
||||
public NetworkingTests()
|
||||
{
|
||||
var engine = new KestrelEngine(LibraryManager, new TestServiceContext());
|
||||
var engine = new KestrelEngine(new TestServiceContext());
|
||||
_uv = engine.Libuv;
|
||||
_logger = engine.Log;
|
||||
}
|
||||
|
||||
ILibraryManager LibraryManager
|
||||
{
|
||||
get
|
||||
{
|
||||
var locator = CallContextServiceLocator.Locator;
|
||||
if (locator == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var services = locator.ServiceProvider;
|
||||
if (services == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (ILibraryManager)services.GetService(typeof(ILibraryManager));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoopCanBeInitAndClose()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Server.Kestrel;
|
||||
using Microsoft.AspNet.Server.Kestrel.Http;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
|
||||
namespace Microsoft.AspNet.Server.KestrelTests
|
||||
|
|
@ -32,33 +30,10 @@ namespace Microsoft.AspNet.Server.KestrelTests
|
|||
Create(app, context, serverAddress);
|
||||
}
|
||||
|
||||
ILibraryManager LibraryManager
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var locator = CallContextServiceLocator.Locator;
|
||||
if (locator == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var services = locator.ServiceProvider;
|
||||
if (services == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (ILibraryManager)services.GetService(typeof(ILibraryManager));
|
||||
}
|
||||
catch (NullReferenceException) { return null; }
|
||||
}
|
||||
}
|
||||
|
||||
public void Create(Func<IFeatureCollection, Task> app, ServiceContext context, string serverAddress)
|
||||
{
|
||||
_engine = new KestrelEngine(
|
||||
LibraryManager,
|
||||
context);
|
||||
_engine = new KestrelEngine(context);
|
||||
_engine.Start(1);
|
||||
_server = _engine.CreateServer(
|
||||
ServerAddress.FromUrl(serverAddress),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel.LibuvCopier
|
||||
|
|
|
|||
Loading…
Reference in New Issue