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