How smallnest/rsocket works
Project Type & Purpose
• This is a Go-based library providing an rsocket protocol over RDMA. It offers a socket-level API that mirrors standard socket functions (with an "r" prefix) and is designed to be easily interchangeable with Go’s native net.Conn interface. The primary purpose is to improve performance by leveraging RDMA while maintaining a familiar interface for network programming. Additionally, several example applications (TCP/UDP clients and servers) are provided to demonstrate its usage.
File Structure
• Top-level project files include configuration files (go.mod, go.sum), documentation (README.md, LICENSE, .gitignore) and two key source code files (rsocket.go and tcp_conn.go) that form the core of the library.
• The examples directory is subdivided into various network communication demo projects: tcp_client, tcp_conn_client, tcp_conn_server, tcp_server, udp_client, udp_server. These illustrate how to integrate and use the library in both TCP and UDP contexts.
a. Core Library:
• "rsocket.go": Implements the core rsocket protocol logic over RDMA.
• "tcp_conn.go": Provides an encapsulation to allow the rsocket interface to be used wherever net.Conn is expected.
b. RDMA Interface:
• Underlying RDMA stack/resource, which is abstracted by the library to deliver high-performance communication.
c. Examples/Demonstration Applications:
• Separate example components for TCP and UDP clients/servers demonstrating different usage scenarios.
d. External Interfaces:
• The standard socket-level API, which applications interface with, mirroring the conventional socket calls but routed through the rsocket implementation.
Depicting Relationships and Interactions
• How the client/server applications call into the rsocket API.
• The rsocket library interacting with the RDMA layer.
• Bidirectional data flow between the application layer and the network/RDMA stack.
• The fact that tcp_conn.go enables seamless integration with existing code that uses net.Conn.
Architectural Patterns & Design Principles
• Abstraction layer: the rsocket API mirrors and extends standard socket calls.
• Separation of concerns: core protocol logic is separated from application-level examples.
• Interoperability: compatibility with net.Conn enables plug-and-play behavior with existing Go network code.
• Layering, where the application/business logic resides at the top, the rsocket library acts as a middleware, and the RDMA and underlying hardware/driver form the base.