Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[自荐][开源] SRPC:支持多ILD、多协议、多操作系统的高性能RPC框架 #1882

Open
holmes1412 opened this issue Aug 7, 2021 · 0 comments

Comments

@holmes1412
Copy link

holmes1412 commented Aug 7, 2021

项目地址

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;

示例代码

#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都可快速访问:

curl 127.0.0.1:8811/Example/Echo -H 'Content-Type: application/json' -d '{message:"from curl",name:"CURL"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants