Skip to content

Commit e798ab5

Browse files
committed
Obsolete the Libuv transport
1 parent 8863eaf commit e798ab5

16 files changed

+52
-0
lines changed

src/Servers/Kestrel/Kestrel/test/WebHostBuilderKestrelExtensionsTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,21 @@ public void SocketTransportIsTheDefault()
6363
[Fact]
6464
public void LibuvTransportCanBeManuallySelectedIndependentOfOrder()
6565
{
66+
#pragma warning disable CS0618
6667
var hostBuilder = new WebHostBuilder()
6768
.UseKestrel()
6869
.UseLibuv()
6970
.Configure(app => { });
71+
#pragma warning restore CS0618
7072

7173
Assert.IsType<LibuvTransportFactory>(hostBuilder.Build().Services.GetService<IConnectionListenerFactory>());
7274

75+
#pragma warning disable CS0618
7376
var hostBuilderReversed = new WebHostBuilder()
7477
.UseLibuv()
7578
.UseKestrel()
7679
.Configure(app => { });
80+
#pragma warning restore CS0618
7781

7882
Assert.IsType<LibuvTransportFactory>(hostBuilderReversed.Build().Services.GetService<IConnectionListenerFactory>());
7983
}

src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvConnectionListener.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public LibuvConnectionListener(LibuvFunctions uv, LibuvTransportContext context,
4040

4141
public IHostApplicationLifetime AppLifetime => TransportContext.AppLifetime;
4242
public ILibuvTrace Log => TransportContext.Log;
43+
44+
#pragma warning disable CS0618
4345
public LibuvTransportOptions TransportOptions => TransportContext.Options;
46+
#pragma warning restore CS0618
4447

4548
public EndPoint EndPoint { get; set; }
4649

@@ -131,7 +134,9 @@ internal async Task BindAsync()
131134
{
132135
// TODO: Move thread management to LibuvTransportFactory
133136
// TODO: Split endpoint management from thread management
137+
#pragma warning disable CS0618
134138
for (var index = 0; index < TransportOptions.ThreadCount; index++)
139+
#pragma warning restore CS0618
135140
{
136141
Threads.Add(new LibuvThread(Libuv, TransportContext));
137142
}
@@ -143,7 +148,9 @@ internal async Task BindAsync()
143148

144149
try
145150
{
151+
#pragma warning disable CS0618
146152
if (TransportOptions.ThreadCount == 1)
153+
#pragma warning restore CS0618
147154
{
148155
var listener = new Listener(TransportContext);
149156
_listeners.Add(listener);

src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
77
{
88
internal class LibuvTransportContext
99
{
10+
#pragma warning disable CS0618
1011
public LibuvTransportOptions Options { get; set; }
12+
#pragma warning restore CS0618
1113

1214
public IHostApplicationLifetime AppLifetime { get; set; }
1315

src/Servers/Kestrel/Transport.Libuv/src/Internal/LibuvTransportFactory.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ internal class LibuvTransportFactory : IConnectionListenerFactory
1717
private readonly LibuvTransportContext _baseTransportContext;
1818

1919
public LibuvTransportFactory(
20+
#pragma warning disable CS0618
2021
IOptions<LibuvTransportOptions> options,
22+
#pragma warning restore CS0618
2123
IHostApplicationLifetime applicationLifetime,
2224
ILoggerFactory loggerFactory)
2325
{
@@ -37,7 +39,9 @@ public LibuvTransportFactory(
3739
var logger = loggerFactory.CreateLogger("Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv");
3840
var trace = new LibuvTrace(logger);
3941

42+
#pragma warning disable CS0618
4043
var threadCount = options.Value.ThreadCount;
44+
#pragma warning restore CS0618
4145

4246
if (threadCount <= 0)
4347
{

src/Servers/Kestrel/Transport.Libuv/src/Internal/Listener.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public Task StartAsync(
3737
return Thread.PostAsync(listener =>
3838
{
3939
listener.ListenSocket = listener.CreateListenSocket();
40+
#pragma warning disable CS0618
4041
listener.ListenSocket.Listen(TransportContext.Options.Backlog, ConnectionCallback, listener);
42+
#pragma warning restore CS0618
4143
}, this);
4244
}
4345

@@ -66,7 +68,9 @@ private UvTcpHandle ListenTcp(bool useFileHandle)
6668
try
6769
{
6870
socket.Init(Thread.Loop, Thread.QueueCloseHandle);
71+
#pragma warning disable CS0618
6972
socket.NoDelay(TransportContext.Options.NoDelay);
73+
#pragma warning restore CS0618
7074

7175
if (!useFileHandle)
7276
{

src/Servers/Kestrel/Transport.Libuv/src/Internal/ListenerContext.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ protected internal void HandleConnection(UvStreamHandle socket)
109109
}
110110

111111
var options = TransportContext.Options;
112+
#pragma warning disable CS0618
112113
var connection = new LibuvConnection(socket, TransportContext.Log, Thread, remoteEndPoint, localEndPoint, InputOptions, OutputOptions, options.MaxReadBufferSize, options.MaxWriteBufferSize);
114+
#pragma warning restore CS0618
113115
connection.Start();
114116

115117
bool accepted = _acceptQueue.Writer.TryWrite(connection);
@@ -128,7 +130,9 @@ private UvTcpHandle AcceptTcp()
128130
try
129131
{
130132
socket.Init(Thread.Loop, Thread.QueueCloseHandle);
133+
#pragma warning disable CS0618
131134
socket.NoDelay(TransportContext.Options.NoDelay);
135+
#pragma warning restore CS0618
132136
}
133137
catch
134138
{

src/Servers/Kestrel/Transport.Libuv/src/Internal/ListenerPrimary.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ private void PostCallback()
6969
ListenPipe = new UvPipeHandle(Log);
7070
ListenPipe.Init(Thread.Loop, Thread.QueueCloseHandle, false);
7171
ListenPipe.Bind(_pipeName);
72+
#pragma warning disable CS0618
7273
ListenPipe.Listen(TransportContext.Options.Backlog,
7374
(pipe, status, error, state) => ((ListenerPrimary)state).OnListenPipe(pipe, status, error), this);
75+
#pragma warning restore CS0618
7476
}
7577

7678
private void OnListenPipe(UvStreamHandle pipe, int status, UvException error)

src/Servers/Kestrel/Transport.Libuv/src/LibuvTransportOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv
99
/// <summary>
1010
/// Provides programmatic configuration of Libuv transport features.
1111
/// </summary>
12+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
1213
public class LibuvTransportOptions
1314
{
1415
/// <summary>
@@ -17,6 +18,7 @@ public class LibuvTransportOptions
1718
/// <remarks>
1819
/// Defaults to half of <see cref="Environment.ProcessorCount" /> rounded down and clamped between 1 and 16.
1920
/// </remarks>
21+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
2022
public int ThreadCount { get; set; } = ProcessorThreadCount;
2123

2224
/// <summary>
@@ -25,6 +27,7 @@ public class LibuvTransportOptions
2527
/// <remarks>
2628
/// Defaults to true.
2729
/// </remarks>
30+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
2831
public bool NoDelay { get; set; } = true;
2932

3033
/// <summary>
@@ -33,10 +36,13 @@ public class LibuvTransportOptions
3336
/// <remarks>
3437
/// Defaults to 128.
3538
/// </remarks>
39+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
3640
public int Backlog { get; set; } = 128;
3741

42+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
3843
public long? MaxReadBufferSize { get; set; } = 1024 * 1024;
3944

45+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
4046
public long? MaxWriteBufferSize { get; set; } = 64 * 1024;
4147

4248
internal Func<MemoryPool<byte>> MemoryPoolFactory { get; set; } = System.Buffers.SlabMemoryPoolFactory.Create;

src/Servers/Kestrel/Transport.Libuv/src/WebHostBuilderLibuvExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Microsoft.AspNetCore.Hosting
1111
{
12+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
1213
public static class WebHostBuilderLibuvExtensions
1314
{
1415
/// <summary>
@@ -20,6 +21,7 @@ public static class WebHostBuilderLibuvExtensions
2021
/// <returns>
2122
/// The Microsoft.AspNetCore.Hosting.IWebHostBuilder.
2223
/// </returns>
24+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
2325
public static IWebHostBuilder UseLibuv(this IWebHostBuilder hostBuilder)
2426
{
2527
return hostBuilder.ConfigureServices(services =>
@@ -40,6 +42,7 @@ public static IWebHostBuilder UseLibuv(this IWebHostBuilder hostBuilder)
4042
/// <returns>
4143
/// The Microsoft.AspNetCore.Hosting.IWebHostBuilder.
4244
/// </returns>
45+
[Obsolete("The libuv transport is obsolete and will be removed in a future release. See https://aka.ms/libuvtransport for details.", error: false)]
4346
public static IWebHostBuilder UseLibuv(this IWebHostBuilder hostBuilder, Action<LibuvTransportOptions> configureOptions)
4447
{
4548
return hostBuilder.UseLibuv().ConfigureServices(services =>

src/Servers/Kestrel/Transport.Libuv/test/LibuvTransportFactoryTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public class LibuvTransportFactoryTests
1818
[InlineData(-1337)]
1919
public void StartWithNonPositiveThreadCountThrows(int threadCount)
2020
{
21+
#pragma warning disable CS0618
2122
var options = new LibuvTransportOptions { ThreadCount = threadCount };
23+
#pragma warning restore CS0618
2224

2325
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
2426
new LibuvTransportFactory(Options.Create(options), new LifetimeNotImplemented(), Mock.Of<ILoggerFactory>()));
@@ -30,7 +32,9 @@ public void StartWithNonPositiveThreadCountThrows(int threadCount)
3032
public void LoggerCategoryNameIsLibuvTransportNamespace()
3133
{
3234
var mockLoggerFactory = new Mock<ILoggerFactory>();
35+
#pragma warning disable CS0618
3336
new LibuvTransportFactory(Options.Create<LibuvTransportOptions>(new LibuvTransportOptions()), new LifetimeNotImplemented(), mockLoggerFactory.Object);
37+
#pragma warning restore CS0618
3438
mockLoggerFactory.Verify(factory => factory.CreateLogger("Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv"));
3539
}
3640
}

0 commit comments

Comments
 (0)