Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1 KB

README.md

File metadata and controls

49 lines (39 loc) · 1 KB

Introduce

Tinyrpc是一个轻量级的RPC框架,该框架采用第三方库rapidjson实现JSON的序列化和反序列化,依靠Tinynet传输消息。

Install

$ git clone [email protected]:bbbgan/tinynet.git
$ cd tinynet && ./build.sh

How to Use

定义Json文件Arithmetic.json: name是方法的名称,params是方法的参数,return是返回值。

{
  "name": "Arithmetic",
  "rpc": [
    {
      "name": "Add",
      "params": {"lhs": 0.0, "rhs": 0.0},
      "returns": 0.0
    },
    {
      "name": "Sub",
      "params": {"lhs": 0.0, "rhs": 0.0},
      "returns": 0.0
    },
    {
      "name": "Mul",
      "params": {"lhs": 0.0, "rhs": 0.0},
      "returns": 0.0
    },
  ]
}

生成Stub头文件

$ tinyrpcstub -c -s -i Arithmetic.json

include头文件,重写基类的方法,即可发起RPC服务,具体的可以参考example

TODO

  • DOCTESTS
  • more example