Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement new bedrock listener abstraction and re-plat Kestrel on top #10321

Merged
merged 78 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
42622b7
Spike Kestrel with new transport abstraction.
davidfowl May 17, 2019
5d91d92
Libuv works
davidfowl May 17, 2019
b4e7ac8
Removed features
davidfowl May 17, 2019
a605520
Added EndPoint to IConnectionListener
davidfowl May 17, 2019
582cbbf
Remove null check
davidfowl May 17, 2019
6d539b1
Null means no more connections
davidfowl May 17, 2019
2c797d0
More cleanup
davidfowl May 18, 2019
daec056
Endpoint -> EndPoint
davidfowl May 18, 2019
a2281c2
Generate the connection id in kestrel
davidfowl May 18, 2019
c471ce0
Implement shutdown in the socket transport
davidfowl May 19, 2019
3f864d4
Progress towards removing the task
davidfowl May 19, 2019
60efcbd
Remove the KestrelConnection cast
davidfowl May 19, 2019
17fa5fc
Remove IHttpConnectionFeature
davidfowl May 19, 2019
789ae16
Remove comment
davidfowl May 19, 2019
edf0557
Fix in memory transport
davidfowl May 19, 2019
c1f9f13
Make more tests compile
davidfowl May 19, 2019
834811f
Use the memory pool
davidfowl May 19, 2019
7592ba4
Move graceful shutdown back to the caller
davidfowl May 23, 2019
2ff8603
More clean up
davidfowl May 23, 2019
f44caae
Revert making LibuvTransportFactory public
davidfowl May 23, 2019
1e4fcfe
Minor clean up
davidfowl May 23, 2019
3303a6a
Shifting and deleting things
davidfowl May 23, 2019
603aff3
Make more tests compile
davidfowl May 23, 2019
178a5c2
Make it all compile
davidfowl May 23, 2019
e98e534
Use the scheduler in the InMemoryTransport
davidfowl May 24, 2019
ca66f11
Use options
davidfowl May 24, 2019
4d85641
Fixed port binding
davidfowl May 24, 2019
cb665fc
Made ListenOptinos.IPEndPoint readonly
davidfowl May 24, 2019
7e8c1fe
Fix libuv binding
davidfowl May 24, 2019
cd12e5e
Make IPEndPoint work on ListenOptions
davidfowl May 24, 2019
e06f099
More tests passing
davidfowl May 24, 2019
9990930
EndPoint is the source of truth for binding
davidfowl May 24, 2019
cdf5213
Fixed test
davidfowl May 24, 2019
ec6ae60
Minor clean up
davidfowl May 24, 2019
a5838f2
Fixed cloning listen options
davidfowl May 24, 2019
fcdf072
Wait for the accept loop to end
davidfowl May 24, 2019
1b9f718
Clean up ConnectionManager
davidfowl May 24, 2019
5d2d82e
PR feedback
davidfowl May 25, 2019
34dc284
Fixed timeout tests
davidfowl May 25, 2019
1a5652e
Made more libuv tests pass
davidfowl May 25, 2019
a105f8b
Fixed one more test
davidfowl May 25, 2019
5ecfb4f
Wait for connection close to fire before disposing the token
davidfowl May 25, 2019
2e2e2b5
Make last libuv test work
davidfowl May 25, 2019
85f16f9
Wait for the token to fire before disposing
davidfowl May 25, 2019
9e5cd63
Transport is responsible for waiting on the token to fire
davidfowl May 25, 2019
c5b27b2
Wrote a test for unaccepted connections
davidfowl May 25, 2019
c41a6ab
Added support for setting the read and write buffers on each transport
davidfowl May 26, 2019
ba6ae60
Update the refs
davidfowl May 26, 2019
77d3c27
Remove scheduling mode
davidfowl May 26, 2019
4977f1b
Fixed fallout from adding DisposeAsync to ConnectionContext
davidfowl May 26, 2019
83754d2
Generated ref for connection abstractions
davidfowl May 26, 2019
eb73fc8
Rename StopAsync to UnbindAsync and added ct to args
davidfowl May 26, 2019
cbf6063
Added some more LibuvTransportTests
davidfowl May 26, 2019
1c29e3b
Moved TransportConnection to Connections.Abstractions
davidfowl May 26, 2019
288d4e0
Updated refs
davidfowl May 26, 2019
dd162c9
Moved FileHandleEndPoint to Connections.Abstractions
davidfowl May 26, 2019
e0f1348
Remove dependency on Transport.Abstractions
davidfowl May 26, 2019
13a8b49
Updated the refs
davidfowl May 26, 2019
89c6410
Fixed breaks after rebase
davidfowl May 27, 2019
3301c1e
Handle a null pool
davidfowl May 27, 2019
148bcfa
Fixed segment size
davidfowl May 27, 2019
0930aa6
Updated the ref
davidfowl May 27, 2019
8a91fb1
Use the right scheduler
davidfowl May 27, 2019
dbe8832
Skip ParseAddressUnixPipe on windows 7
davidfowl May 27, 2019
bf48a2a
Only run unix pipe test on windows10
davidfowl May 27, 2019
ff56f85
Don't capture the sync context
davidfowl May 27, 2019
f0e7f42
Some PR feedback
davidfowl May 28, 2019
1a143b7
PR feedback and fixes
davidfowl May 28, 2019
f918162
Handle connection resets in accept
davidfowl May 28, 2019
f6fe012
Set NoDelay to true by default
davidfowl May 29, 2019
98d6afb
Update the ref assembly
davidfowl May 29, 2019
e488e07
PR feedback
davidfowl May 29, 2019
9e341c3
Handle connection reset
davidfowl May 29, 2019
21ac350
Some cleanup
davidfowl May 30, 2019
940e6fa
Make everything async and clean up the accept loop
davidfowl May 30, 2019
1cec23c
Improve aborting queued connection logic
davidfowl May 30, 2019
c4cdab0
Added logs
davidfowl May 30, 2019
74868c1
Log critical for ungraceful loop shutdown
davidfowl May 30, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ public static partial class ConnectionBuilderExtensions
public abstract partial class ConnectionContext
halter73 marked this conversation as resolved.
Show resolved Hide resolved
{
protected ConnectionContext() { }
public virtual System.Threading.CancellationToken ConnectionClosed { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public abstract string ConnectionId { get; set; }
public abstract Microsoft.AspNetCore.Http.Features.IFeatureCollection Features { get; }
public abstract System.Collections.Generic.IDictionary<object, object> Items { get; set; }
public virtual System.Net.EndPoint LocalEndPoint { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public virtual System.Net.EndPoint RemoteEndPoint { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public abstract System.IO.Pipelines.IDuplexPipe Transport { get; set; }
public virtual void Abort() { }
public virtual void Abort(Microsoft.AspNetCore.Connections.ConnectionAbortedException abortReason) { }
public virtual System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
}
public delegate System.Threading.Tasks.Task ConnectionDelegate(Microsoft.AspNetCore.Connections.ConnectionContext connection);
public abstract partial class ConnectionHandler
Expand Down Expand Up @@ -70,40 +74,97 @@ public partial class ConnectionResetException : System.IO.IOException
public ConnectionResetException(string message) { }
public ConnectionResetException(string message, System.Exception inner) { }
}
public partial class DefaultConnectionContext : Microsoft.AspNetCore.Connections.ConnectionContext, Microsoft.AspNetCore.Connections.Features.IConnectionIdFeature, Microsoft.AspNetCore.Connections.Features.IConnectionItemsFeature, Microsoft.AspNetCore.Connections.Features.IConnectionLifetimeFeature, Microsoft.AspNetCore.Connections.Features.IConnectionTransportFeature, Microsoft.AspNetCore.Connections.Features.IConnectionUserFeature, System.IDisposable
public partial class DefaultConnectionContext : Microsoft.AspNetCore.Connections.ConnectionContext, Microsoft.AspNetCore.Connections.Features.IConnectionEndPointFeature, Microsoft.AspNetCore.Connections.Features.IConnectionIdFeature, Microsoft.AspNetCore.Connections.Features.IConnectionItemsFeature, Microsoft.AspNetCore.Connections.Features.IConnectionLifetimeFeature, Microsoft.AspNetCore.Connections.Features.IConnectionTransportFeature, Microsoft.AspNetCore.Connections.Features.IConnectionUserFeature, System.IDisposable
halter73 marked this conversation as resolved.
Show resolved Hide resolved
{
public DefaultConnectionContext() { }
public DefaultConnectionContext(string id) { }
public DefaultConnectionContext(string id, System.IO.Pipelines.IDuplexPipe transport, System.IO.Pipelines.IDuplexPipe application) { }
public System.IO.Pipelines.IDuplexPipe Application { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public System.Threading.CancellationToken ConnectionClosed { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override System.Threading.CancellationToken ConnectionClosed { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override string ConnectionId { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override Microsoft.AspNetCore.Http.Features.IFeatureCollection Features { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public override System.Collections.Generic.IDictionary<object, object> Items { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override System.Net.EndPoint LocalEndPoint { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override System.Net.EndPoint RemoteEndPoint { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override System.IO.Pipelines.IDuplexPipe Transport { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public System.Security.Claims.ClaimsPrincipal User { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override void Abort(Microsoft.AspNetCore.Connections.ConnectionAbortedException abortReason) { }
public void Dispose() { }
public override System.Threading.Tasks.ValueTask DisposeAsync() { throw null; }
}
public partial class FileHandleEndPoint : System.Net.EndPoint
{
public FileHandleEndPoint(ulong fileHandle, Microsoft.AspNetCore.Connections.FileHandleType fileHandleType) { }
public ulong FileHandle { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Connections.FileHandleType FileHandleType { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public enum FileHandleType
{
Auto = 0,
Tcp = 1,
Pipe = 2,
}
public partial interface IConnectionBuilder
{
System.IServiceProvider ApplicationServices { get; }
Microsoft.AspNetCore.Connections.ConnectionDelegate Build();
Microsoft.AspNetCore.Connections.IConnectionBuilder Use(System.Func<Microsoft.AspNetCore.Connections.ConnectionDelegate, Microsoft.AspNetCore.Connections.ConnectionDelegate> middleware);
}
public partial interface IConnectionListener
{
System.Net.EndPoint EndPoint { get; }
System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext> AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
System.Threading.Tasks.ValueTask DisposeAsync();
System.Threading.Tasks.ValueTask UnbindAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
}
public partial interface IConnectionListenerFactory
{
System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.IConnectionListener> BindAsync(System.Net.EndPoint endpoint, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
}
[System.FlagsAttribute]
public enum TransferFormat
{
Binary = 1,
Text = 2,
}
public abstract partial class TransportConnection : Microsoft.AspNetCore.Connections.ConnectionContext, Microsoft.AspNetCore.Connections.Features.IConnectionIdFeature, Microsoft.AspNetCore.Connections.Features.IConnectionItemsFeature, Microsoft.AspNetCore.Connections.Features.IConnectionLifetimeFeature, Microsoft.AspNetCore.Connections.Features.IConnectionTransportFeature, Microsoft.AspNetCore.Connections.Features.IMemoryPoolFeature, Microsoft.AspNetCore.Http.Features.IFeatureCollection, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Type, object>>, System.Collections.IEnumerable
{
public TransportConnection() { }
public System.IO.Pipelines.IDuplexPipe Application { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override System.Threading.CancellationToken ConnectionClosed { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override string ConnectionId { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override Microsoft.AspNetCore.Http.Features.IFeatureCollection Features { get { throw null; } }
public override System.Collections.Generic.IDictionary<object, object> Items { get { throw null; } set { } }
public override System.Net.EndPoint LocalEndPoint { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public virtual System.Buffers.MemoryPool<byte> MemoryPool { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
System.Collections.Generic.IDictionary<object, object> Microsoft.AspNetCore.Connections.Features.IConnectionItemsFeature.Items { get { throw null; } set { } }
System.Threading.CancellationToken Microsoft.AspNetCore.Connections.Features.IConnectionLifetimeFeature.ConnectionClosed { get { throw null; } set { } }
System.IO.Pipelines.IDuplexPipe Microsoft.AspNetCore.Connections.Features.IConnectionTransportFeature.Transport { get { throw null; } set { } }
System.Buffers.MemoryPool<byte> Microsoft.AspNetCore.Connections.Features.IMemoryPoolFeature.MemoryPool { get { throw null; } }
bool Microsoft.AspNetCore.Http.Features.IFeatureCollection.IsReadOnly { get { throw null; } }
object Microsoft.AspNetCore.Http.Features.IFeatureCollection.this[System.Type key] { get { throw null; } set { } }
int Microsoft.AspNetCore.Http.Features.IFeatureCollection.Revision { get { throw null; } }
public override System.Net.EndPoint RemoteEndPoint { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override System.IO.Pipelines.IDuplexPipe Transport { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
public override void Abort(Microsoft.AspNetCore.Connections.ConnectionAbortedException abortReason) { }
void Microsoft.AspNetCore.Connections.Features.IConnectionLifetimeFeature.Abort() { }
TFeature Microsoft.AspNetCore.Http.Features.IFeatureCollection.Get<TFeature>() { throw null; }
void Microsoft.AspNetCore.Http.Features.IFeatureCollection.Set<TFeature>(TFeature feature) { }
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.Type, object>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.Type,System.Object>>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
}
}
namespace Microsoft.AspNetCore.Connections.Features
{
public partial interface IConnectionCompleteFeature
{
void OnCompleted(System.Func<object, System.Threading.Tasks.Task> callback, object state);
}
public partial interface IConnectionEndPointFeature
{
System.Net.EndPoint LocalEndPoint { get; set; }
System.Net.EndPoint RemoteEndPoint { get; set; }
}
public partial interface IConnectionHeartbeatFeature
{
void OnHeartbeat(System.Action<object> action, object state);
Expand Down
14 changes: 14 additions & 0 deletions src/Servers/Connections.Abstractions/src/ConnectionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

using System.Collections.Generic;
using System.IO.Pipelines;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Features;

Expand All @@ -18,6 +21,12 @@ public abstract class ConnectionContext

public abstract IDuplexPipe Transport { get; set; }

public virtual CancellationToken ConnectionClosed { get; set; }

public virtual EndPoint LocalEndPoint { get; set; }

public virtual EndPoint RemoteEndPoint { get; set; }

davidfowl marked this conversation as resolved.
Show resolved Hide resolved
public virtual void Abort(ConnectionAbortedException abortReason)
{
// We expect this to be overridden, but this helps maintain back compat
Expand All @@ -27,5 +36,10 @@ public virtual void Abort(ConnectionAbortedException abortReason)
}

public virtual void Abort() => Abort(new ConnectionAbortedException("The connection was aborted by the application via ConnectionContext.Abort()."));

public virtual ValueTask DisposeAsync()
{
return default;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Threading.Tasks;
// 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.Threading.Tasks;

namespace Microsoft.AspNetCore.Connections
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using System;
using System.Collections.Generic;
using System.IO.Pipelines;
using System.Net;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Features;

Expand All @@ -17,7 +19,8 @@ public class DefaultConnectionContext : ConnectionContext,
IConnectionItemsFeature,
IConnectionTransportFeature,
IConnectionUserFeature,
IConnectionLifetimeFeature
IConnectionLifetimeFeature,
IConnectionEndPointFeature
{
private CancellationTokenSource _connectionClosedTokenSource = new CancellationTokenSource();

Expand All @@ -42,6 +45,7 @@ public DefaultConnectionContext(string id)
Features.Set<IConnectionIdFeature>(this);
Features.Set<IConnectionTransportFeature>(this);
Features.Set<IConnectionLifetimeFeature>(this);
Features.Set<IConnectionEndPointFeature>(this);
}

public DefaultConnectionContext(string id, IDuplexPipe transport, IDuplexPipe application)
Expand All @@ -63,7 +67,9 @@ public DefaultConnectionContext(string id, IDuplexPipe transport, IDuplexPipe ap

public override IDuplexPipe Transport { get; set; }

public CancellationToken ConnectionClosed { get; set; }
public override CancellationToken ConnectionClosed { get; set; }
public override EndPoint LocalEndPoint { get; set; }
public override EndPoint RemoteEndPoint { get; set; }

public override void Abort(ConnectionAbortedException abortReason)
{
Expand All @@ -74,5 +80,11 @@ public void Dispose()
{
_connectionClosedTokenSource.Dispose();
}

public override ValueTask DisposeAsync()
{
_connectionClosedTokenSource.Dispose();
return base.DisposeAsync();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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.Net;
halter73 marked this conversation as resolved.
Show resolved Hide resolved

namespace Microsoft.AspNetCore.Connections.Features
{
public interface IConnectionEndPointFeature
{
EndPoint LocalEndPoint { get; set; }
EndPoint RemoteEndPoint { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// 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.Security.Claims;

namespace Microsoft.AspNetCore.Connections.Features
Expand All @@ -6,4 +9,4 @@ public interface IConnectionUserFeature
{
ClaimsPrincipal User { get; set; }
}
}
}
30 changes: 30 additions & 0 deletions src/Servers/Connections.Abstractions/src/FileHandleEndPoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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;
using System.Net;

namespace Microsoft.AspNetCore.Connections
{
public class FileHandleEndPoint : EndPoint
{
public FileHandleEndPoint(ulong fileHandle, FileHandleType fileHandleType)
{
FileHandle = fileHandle;
FileHandleType = fileHandleType;

switch (fileHandleType)
{
case FileHandleType.Auto:
case FileHandleType.Tcp:
case FileHandleType.Pipe:
break;
default:
throw new NotSupportedException();
}
}

public ulong FileHandle { get; }
public FileHandleType FileHandleType { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.

namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
namespace Microsoft.AspNetCore.Connections
{
/// <summary>
/// Enumerates the <see cref="IEndPointInformation.FileHandle"/> types.
/// Enumerates the <see cref="FileHandleEndPoint"/> types.
/// </summary>
public enum FileHandleType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// 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;

namespace Microsoft.AspNetCore.Connections
{
Expand Down
20 changes: 20 additions & 0 deletions src/Servers/Connections.Abstractions/src/IConnectionListener.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.Net;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.AspNetCore.Connections
{
public interface IConnectionListener
{
EndPoint EndPoint { get; }

ValueTask<ConnectionContext> AcceptAsync(CancellationToken cancellationToken = default);

ValueTask UnbindAsync(CancellationToken cancellationToken = default);

ValueTask DisposeAsync();
Copy link
Member

Choose a reason for hiding this comment

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

Should the interface be bassed on IAsyncDisposable?
Same above in ConnectionContext.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I just hacked it because this is ns2.0.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh...thx.

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Microsoft.AspNetCore.Connections
{
public interface IConnectionListenerFactory
Copy link
Member

Choose a reason for hiding this comment

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

How nice would it be to avoid the word factory? Maybe IEndpointBinder?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not changing the name in this PR, we agreed to this one in the meeting, we can iterate on the issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

That said, I don't disagree

{
ValueTask<IConnectionListener> BindAsync(EndPoint endpoint, CancellationToken cancellationToken = default);
}
}
Loading