-
Notifications
You must be signed in to change notification settings - Fork 158
Description
Hi,
I am making use of Bedrock or at least some components of Bedrock in building a small framework for multiprotocol Kestrel based services.
Briefly the design is as follows :
When an app based on the framework is launched it starts up a (parent) Kestrel service bound to a socket.
In addition a pool of AssemblyLoadContexts are spun up.
Each of these ALCs hosts an instance of a (child) Kestrel.
Each child Kestrel however is bound to a (Bedrock) MemoryEndPoint not a socket.
The parent Kestrel is enhanced with a connectionhandler that dispatches each incoming ConnectionContext to an available child Kestrel from the pool.
All of this works and works very well ….. WITH a small modifcation.
Kestrel will only bind to an IPEndPoint not an EndPoint. I therefore modified Bedrock.Framework/Transports/Memory/MemoryEndPoint.cs
to inherit from IPEndPoint and implemented the method Create(SocketAddress) with a no-op.
That’s essentially the design and it meets the requirements.
Further I have also investigated binding the parent Kestrel to a MemoryEndPoint instead of a socket. This was accomplished by adding IConnectionListnerFactory & IConnectionFactory to the service provider.
This ability would certainly be quite useful for testing. However when the ConnectionContext (born in the MemoryTransport) is sent down the kestrel pipeline a NullReferenceException is thrown . It transpires that the feature IMemoryPoolFeature is required and missing. When this feature is set on the ConnectionContext everything appears to work.
What doesn't work however is if you want to simultaneously bind your parent kestrel to a socket AND a MemoryEndPoint. This would again be a very useful feature.
Can it be envisaged that some of these quite modest modifications be added to Bedrock ? Currently I am taking the source files from Bedrock but would prefer to take them and leave them unmodified.
I have spoken with @Drawaes and he told me MemoryEndPoint was never designed to be used with Kestrel. But it could be :-)
Thanks
N