A distributed C++ RPC framework built on C++20 coroutines, Google Protobuf, Tencent LLBC, and Zookeeper.
Design document: https://www.processon.com/view/link/674fc43f51e6566236b8c764?cid=645b8e4f34a3ca40d19073a2
- Coroutine-based RPC: Uses C++20 coroutines to provide a simple, synchronous-style API for asynchronous RPC calls.
- Service discovery: Integrates with Zookeeper for service registration and discovery.
- Protobuf-based interfaces: RPC request/response types are defined using Google Protobuf.
- LLBC networking: Uses Tencent LLBC as the underlying networking layer.
src/: Core RPC implementation (channels, controllers, service manager, registry, client/server, etc.).3rd/: Third-party dependencies (protobuf, llbc, fmt, etc.).build/: CMake build output (generated after configuring/building).CMakeLists.txt: Top-level CMake configuration.
- A C++20-capable compiler (e.g. GCC 11+, Clang 13+).
- CMake 3.16+.
- Zookeeper runtime/server accessible for service registration.
Note: Third-party libraries (
protobuf,llbc,fmt, etc.) are vendored under3rd/and are wired via CMake. You generally don’t need to install them system-wide.
From the project root:
mkdir -p build
cd build
cmake ..
cmake --build . -j$(nproc)This will build the main RPC library/binaries defined in src/ (such as client/server executables if present in CMakeLists.txt).
- Start Zookeeper and ensure it is reachable at the address used by the code (for example
127.0.0.1:2181, as seen inRpcServiceMgr::Init). - Start your RPC server:
- Implement your own Protobuf services.
- Register them with
RpcServiceMgr::AddService. - Start the underlying LLBC network server and RPC connection manager.
- Start your RPC client:
- Use
RpcServiceMgr::RegisterRpcChannelto obtain a channel to a service. - Invoke the generated Protobuf stubs over that channel (using coroutine or blocking style depending on your controller usage).
- Use
Since this repo focuses on the core framework, typical server/client wiring code lives in the src/ directory—check the examples there when exploring.
- Server registers Protobuf services with
RpcServiceMgr. - On startup, the service manager registers each service/method in Zookeeper (
service_name.method_name -> ip:port). - Client resolves a service via Zookeeper and opens an
RpcChannel. - An RPC request is sent over LLBC, deserialized by
RpcServiceMgr::HandleRpcReq, dispatched to the target Protobuf service, and the response is serialized and returned fromRpcServiceMgr::OnRpcDone. - Client-side coroutine (managed by
RpcCoroMgr) resumes when the response arrives inRpcServiceMgr::HandleRpcRsp.
This project is under active development and the APIs may change. Use it as a reference implementation or starting point for coroutine-based RPC with LLBC, Zookeeper, and Protobuf.