sogou / srpc

RPC framework based on C++ Workflow. Supports SRPC, Baidu bRPC, Tencent tRPC, thrift protocols.
Apache License 2.0
1.95k stars 386 forks source link

Support RPC Transcoding for SRPCHttpServer #405

Open holmes1412 opened 2 months ago

holmes1412 commented 2 months ago

Mentioned in this issue : https://github.com/sogou/srpc/issues/404

TODO:

holmes1412 commented 3 weeks ago

补充关于trans_code转换的描述,如何将 request_uri通过path_map查找到service和method。

1. initialization

server.add_service(my_example_service, '{ "/echo_a" : "Echo", "/echo_b" : "Echo"}');

这里会为server的path_map增加针对example_service的两个映射:

同时,为server的service_map增加一个查找service对象的映射(原有逻辑):

2. query

  1. 如果是SRPCHttp:先把HTTP的request_uri(比如"/echo_a")通过path_map找到原始映射(比如"/Example/Echo"),设置到request_uri上;

  2. 继续走正常的server_process()流程,从request_uri拆'/'得出第一段(比如"/Example"),通过service_map查找出service对象,再调service对象的find_method()找后面部分对应的RPC函数。