Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

davidfowl
Copy link
Member

  • Made the unix domain sockets test use it

I'd like to have more than one implementation of the IConnectionFactory to make sure the API is sound. This is one potential implementation.


await socket.ConnectAsync(endPoint);

var connection = new SocketConnection(socket, memoryPool: null, PipeScheduler.ThreadPool, new SocketsTrace(_logger));
Copy link
Member Author

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.

Copy link
Member

@halter73 halter73 Jun 28, 2019

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep

@Eilon Eilon added the area-signalr Includes: SignalR clients and servers label Jun 28, 2019
@davidfowl davidfowl added area-servers and removed area-signalr Includes: SignalR clients and servers labels Jun 28, 2019
@davidfowl davidfowl requested review from analogrelay, halter73 and shirhatti and removed request for analogrelay June 28, 2019 04:03
@analogrelay analogrelay added this to the 3.0.0-preview8 milestone Jun 28, 2019

namespace System.IO.Pipelines
{
public static class PipeReaderExtensions
Copy link
Member

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?

Copy link
Member Author

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
@davidfowl davidfowl added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Jul 24, 2019
- Added shared options between server and client
- Null memory pool
@davidfowl davidfowl force-pushed the davidfowl/sockets-client branch from 0a02c24 to e33f2d6 Compare July 24, 2019 05:16
@davidfowl
Copy link
Member Author

@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;
Copy link
Member

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.

Copy link
Member

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)
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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();

@analogrelay analogrelay removed this from the 3.0.0-preview8 milestone Jul 25, 2019
@davidfowl
Copy link
Member Author

@aspnet-hello
Copy link

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)
https://github.com/aspnet/AspNetCore-Internal/issues/2293

@davidfowl
Copy link
Member Author

@anurse I want to get something like this in 3.1. Lets discuss next week on possibilities.

@davidfowl davidfowl closed this Sep 11, 2019
@dougbu dougbu deleted the davidfowl/sockets-client branch May 18, 2020 19:42
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants