Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
wangyilin 8291ccb36d | 2 years ago | |
---|---|---|
.. | ||
img | 3 years ago | |
Archive.h | 2 years ago | |
ArenaAllocator.cpp | 2 years ago | |
ArenaAllocator.h | 3 years ago | |
Dealer.cpp | 3 years ago | |
Dealer.h | 3 years ago | |
Design_cn.md | 2 years ago | |
FrontEnd.cpp | 3 years ago | |
FrontEnd.h | 3 years ago | |
LazyArchive.h | 3 years ago | |
Master.cpp | 3 years ago | |
Master.h | 3 years ago | |
MasterClient.cpp | 3 years ago | |
MasterClient.h | 3 years ago | |
README.md | 2 years ago | |
README_cn.md | 2 years ago | |
RdmaContext.h | 2 years ago | |
RdmaSocket.cpp | 2 years ago | |
RdmaSocket.h | 3 years ago | |
RpcClient.cpp | 3 years ago | |
RpcClient.h | 3 years ago | |
RpcContext.cpp | 3 years ago | |
RpcContext.h | 3 years ago | |
RpcMessage.cpp | 3 years ago | |
RpcMessage.h | 3 years ago | |
RpcServer.cpp | 3 years ago | |
RpcServer.h | 3 years ago | |
RpcService.cpp | 3 years ago | |
RpcService.h | 3 years ago | |
RpcSocket.cpp | 3 years ago | |
RpcSocket.h | 3 years ago | |
TcpMasterClient.cpp | 3 years ago | |
TcpSocket.cpp | 2 years ago | |
TcpSocket.h | 3 years ago | |
ZkMasterClient.cpp | 3 years ago | |
fetch_ip.cpp | 3 years ago | |
fetch_ip.h | 3 years ago | |
masterd.cc | 3 years ago |
English version | 中文版
The following is a simple client-server communication example.
First create a master. A master is a namespace, which maintains the global information of all servers and clients. The server needs to be registered on the master, and the client can access all the registered servers after connecting to the master.
Master master("127.0.0.1:9394");
master.initialize();
master.finalize();
Then use the master endpoint to initialize the prpc framework.
TcpMasterClient master_client(master.endpoint());
master_client.initialize();
RpcService rpc;
RpcConfig rpc_config;
rpc_config.bind_ip = "127.0.0.1";
rpc.initialize(&master_client, rpc_config);
Then create a server. Note that "asdf" here is the service name of the server.
std::unique_ptr<RpcServer> server = rpc.create_server("asdf");
Create a Dealer
for the server. Dealer
is used to send and receive messages and it is not thread-safe while create_dealer
is thread-safe.
std::shared_ptr<Dealer> s_dealer = server->create_dealer();
RpcRequest req;
std::string s;
s_dealer->recv_request(req);
RpcResponse resp(req);
req >> s;
resp << s;
s_dealer->send_response(std::move(resp))
Finally, all objects are destructed in order.
s_dealer.reset();
server.reset();
rpc.finalize();
master_client.finalize();
master.exit();
master.finalize();
First connect to the master.
TcpMasterClient master_client("127.0.0.1:9394");
master_client.initialize();
SLOG(INFO) << "Client initialized.";
RpcService rpc;
RpcConfig rpc_config;
rpc_config.bind_ip = "127.0.0.1";
rpc.initialize(&master_client, rpc_config);
Then create a client, where "asdf" is the service name specified when the server was created, and parameter 1 is the count of servers to wait.
std::unique_ptr<RpcClient> client = rpc.create_client("asdf", 1);
auto c_dealer = client->create_dealer();
Send a request and wait the response.
RpcRequest req;
RpcResponse resp;
std::string s = "asdfasdfasdfasf", e;
req << s;
c_dealer->send_request(std::move(req));
c_dealer->recv_response(resp);
resp >> e;
Finally, all objects are destructed in order.
c_dealer.reset();
client.reset();
rpc.finalize();
master_client.finalize();
An RPC framework that provides network communication for high-performance computing, with components such as accumulator.
C++ Markdown CMake Text other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》