-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Spike an IConnectionFactory for the sockets transport #11672
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
Conversation
|
||
await socket.ConnectAsync(endPoint); | ||
|
||
var connection = new SocketConnection(socket, memoryPool: null, PipeScheduler.ThreadPool, new SocketsTrace(_logger)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pool and scheduler might be better as constructor arguments to this factory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I say we should get ahead of this and create and options object (though not necessarily ioptions) before we add too many params to the constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
|
||
namespace System.IO.Pipelines | ||
{ | ||
public static class PipeReaderExtensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who's calling these extension methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests
- Made the unix domain sockets test use it
0a02c24
to
e33f2d6
Compare
@halter73 give this another look. |
/// <summary> | ||
/// The maximum size before the transport will stop proactively reading from the transport. | ||
/// </summary> | ||
public long? MaxReadBufferSize { get; set; } = 1024 * 1024; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is a break from KestrelServerLimits, I think we should standardize on having null be the default value for nullable ints and longs so we can more reasonably change the defaults later. We can use long.MaxValue or -1 to represent unlimited if we feel that's necessary. This should be more consistent with PipeOptions, StreamPipeReaderOptions, and StreamPipeWriterOptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot SocketTransportOptions still derives from this... I guess that means we shouldn't be changing the interpretation of null. It is an inconsistency with PipeOptions, but at leas this is more consistent with other Kestrel-related options I guess 😞
/// </summary> | ||
/// <param name="options">The options for this transport</param> | ||
/// <param name="loggerFactory">The logger factory</param> | ||
public SocketConnectionFactory(IOptions<SocketClientOptions> options, ILoggerFactory loggerFactory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want a client API to take IOptions? Do we expect this normally to be retrieved from a DI container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tough question but a good one. The only client API we have now is DI enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know how we solve this? We leave it DI friendly and then add static factory methods for the non DI case.
var factory = SocketConnectionFactory.Create();
This comment was made automatically. If there is a problem contact [email protected]. I've triaged the above build. I've created/commented on the following issue(s) |
@anurse I want to get something like this in 3.1. Lets discuss next week on possibilities. |
I'd like to have more than one implementation of the
IConnectionFactory
to make sure the API is sound. This is one potential implementation.