Hi everyone,
we are currently planning the architecture of the RSocket protocol implementation using SwiftNIO.
RSocket, much like HTTP2, multiplexes many streams over a single connection e.g. TCP.
The SwiftNIO HTTP2 implementation creates a new HTTP2StreamChannel for each stream and we thought we should do the same for the RSocket implementation.
In the image above you can see a simplified version of our current plan for the Channel and Pipeline setup.
TCP,
LengthFieldBasedFrameDecoder
and LengthFieldPrepender
are already provided by SwiftNIO and can also be replaced by a WebSocket connection.RSocketFrameDecoder
parses a ByteBuffer
into an RSocketFrame
and passes it to the next ChannelHandler.The interesting part happens in the Multiplexer/Demultiplexer. Depending on the Stream ID (
Int32
), which is included in every RSocketFrame
, the Multiplexer may create a new channel, stores it in a dictionary for possible following frames, and forwards the RSocketFrame
to it.
The Channel implementation of HTTP2StreamChannel looks quite complex and we are now looking for a simpler Channel & Multiplexer implementation. We would like to push the whole state logic into a ChannelHandler, if possible.
Does anyone know of a Channel implementation which can be used for this kind of use case?
The multiplexing part sound like a common use case to use.
Also, the child channel for each stream will probably only have one or two ChannelHandler
s. Maybe a channel is to much for this use case and we should just handle message sending/receiving in a custom type.
What are your thought on this part of the Architecture? Any feedback is welcome
PS: We already have a bigger picture which includes initial connection establishment, pipeline setup and other things. If you want, I can post a Diagram of the overall architecture as well.