SRPC

SRPC是搜狗自研的高性能RPC框架,基于Workflow开发,支持多操作系统、多IDL格式、多数据布局、多压缩方式和多通信协议,提供多种RPC协议实现。

项目地址https://github.com/sogou/srpc#### 项目描述这是搜狗自研的基于Workflow的RPC系统: * 支持多种操作系统:Linux | Windows | MacOS; * 支持多种IDL格式:Protobuf | Thrift; * 支持多种数据布局:Protobuf | Thrift Binary | Json; * 支持多种压缩:gzip | zlib | snappy | lz4; * 支持多种通信协议:tcp | http | sctp | ssl | https; * 支持多种RPC协议:SRPC | BRPC | TRPC (目前唯一的TRPC协议开源实现) | Thrift Framed Binary;#### 示例代码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"}'