I think the approach is fine.
Register a RPC paired with channel. Switch on the msg type when receive from TCP , decoding and send to channel.
The upper layer can just use a select on all the receiving channels.
That is very similar to what I have done in raft.
I think one thing we can improve here is that we can try a non-blocking sendMsg when doing broadcast. This can reduce the overall latency if the underlay tcp buffer is full.
But there might be some reason you did a blocking one, so I create this issue.
Also I remember @imoraru talked about multi-threading improvement. But I forgot the details...
I read through the communication layer.
I think the approach is fine. Register a RPC paired with channel. Switch on the msg type when receive from TCP , decoding and send to channel. The upper layer can just use a select on all the receiving channels. That is very similar to what I have done in raft.
I think one thing we can improve here is that we can try a non-blocking
sendMsg
when doing broadcast. This can reduce the overall latency if the underlay tcp buffer is full. But there might be some reason you did a blocking one, so I create this issue.Also I remember @imoraru talked about multi-threading improvement. But I forgot the details...