zchuange commented on issue #3167: URL: https://github.com/apache/brpc/issues/3167#issuecomment-3631970587
> 这个改进建议的目的应该是把新增传输层协议的实现方式改为更集中拓展性更强的实现方式? 嗯,是的,主要为了方便扩展新的传输层协议。 > [#207](https://github.com/apache/brpc/issues/207) 提到的 EndPoint 多形式,[#1560](https://github.com/apache/brpc/pull/1560) 应该实现了。 @chenBright 当前设计Transport接口都是从Socket已有方法抽取出来,并且和底层通信传输层关联性较高的部分,其中tcp endpoint和rdma endpoint均有被这些方法调用访问,为了把不同的endpoint调用拆分到对应的Transport实现类中。这里可以分别衍生出RdmaTransport和TcpTransport承接不同通信endpoint的调用,这样就能降低Socket类扩展新的传输协议成本,只需实现Transport接口部分即可完成新的传输协议对接,以下是对socket类下推方法抽出来的公共接口定义和类图部分可以参考。 Transport接口定义: ``` class Transport{ public: virtual void BeforeRecycled(Socket* socket) = 0; virtual int WaitAndReset(Socket* socket, int32_t expected_nref) = 0; virtual int StartWrite(Socket* socket, WriteRequest* req, WriteOptions& opt) = 0; virtual void* KeepWrite(void* void_arg) = 0; virtual ssize_t DoWrite(Socket* socket, WriteRequest* req) = 0; virtual int OnInputEvent(void* user_data, uint32_t events, bthread_attr_t& thread_attr) = 0; virtual void DebugSocket(std::ostream& ostream, SocketId id) = 0; } ``` Transport结构类图 <img width="836" height="581" alt="Image" src="https://github.com/user-attachments/assets/c7a0c1c1-25cb-480c-9918-5163ade22c5a" /> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
