TarsCloud_TarsCpp/docs/tars_protobuf_cpp.md

45 lines
1.0 KiB
Markdown
Raw Normal View History

2018-09-05 11:26:21 +08:00
# tars֧<73><D6A7>protobuf service<63><65><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽⵽tars<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>protobufЭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щҵ<EFBFBD><EFBFBD>Ǩ<EFBFBD>Ƶ<EFBFBD>tars<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD>proto<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tars<EFBFBD>ļ<EFBFBD>,<2C>dz<EFBFBD><C7B3><EFBFBD><E9B7B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׳<EFBFBD><D7B3><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>tarsʹ<EFBFBD><EFBFBD>protoc<EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>proto<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD>֧<EFBFBD>֣<EFBFBD><EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>tars rpc<70><63><EFBFBD>ش<EFBFBD><D8B4>ʹ<EBA3AC><CAB9>Ǩ<EFBFBD><C7A8>ƽ<EFBFBD><C6BD>ʡ<EFBFBD>ġ<EFBFBD>
## ʹ<>÷<EFBFBD><C3B7><EFBFBD>
### 1. ׼<><D7BC>proto<74>ļ<EFBFBD>
proto<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD>proto2<EFBFBD><EFBFBD>proto3<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD>ע<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**option cc_generic_services=false;**
<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD>Ŀ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dz<EFBFBD>ʹ<EFBFBD><EFBFBD>protoc<EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>pb rpc<70>ӿڣ<D3BF><DAA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>tars<72><73><EFBFBD><EFBFBD><EFBFBD>ӹܣ<D3B9><DCA3><EFBFBD><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD>tars<72><73><EFBFBD>ܵ<EFBFBD>rpc<70>ӿ<EFBFBD>.
һ<EFBFBD><EFBFBD>proto<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
```cpp
syntax = "proto2";
option cc_generic_services=false;
package TestApp;
message PbRequest {
required int32 a = 1;
required int32 b = 2;
}
message PbResponse {
required int32 c = 1;
}
service Hello {
rpc add(PbRequest) returns (PbResponse) {
}
}
```
### 2. ֱ<><D6B1>ִ<EFBFBD><D6B4>make<6B><65><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>tars pb<70><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>makefile.tars<72>ļ<EFBFBD><C4BC>С<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>protocĬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.pb.h<><68>׺,tars<72><73><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>ļ<EFBFBD><C4BC><EFBFBD>׺<EFBFBD><D7BA>.tars.h