SRPC
SRPC是搜狗自研的高性能RPC框架,基于Workflow开发,支持多操作系统、多IDL格式、多数据布局、多压缩方式和多通信协议,提供多种RPC协议实现。
SRPC是搜狗自研的高性能RPC框架,基于Workflow开发,支持多操作系统、多IDL格式、多数据布局、多压缩方式和多通信协议,提供多种RPC协议实现。
cpp#include <stdio.h>#include "example.srpc.h"using namespace srpc;class ExampleServiceImpl : public Example::Service{public: void Echo(EchoRequest *request, EchoResponse *response, RPCContext *ctx) override { response->set_message("Hi, " + request->name()); }};int main(){ SRPCServer server_tcp; SRPCHttpServer server_http; ExampleServiceImpl impl; server_tcp.add_service(&impl); server_http.add_service(&impl); // add the same service impl into two different types of servers server_tcp.start(1412); server_http.start(8811); getchar(); // press "Enter" to end. server_http.stop(); server_tcp.stop(); return 0;}
任何httpclient都可快速访问:shcurl 127.0.0.1:8811/Example/Echo -H 'Content-Type: application/json' -d '{message:"from curl",name:"CURL"}'