google的语言中立、平台中立、开源的远程过程调用(RPC)的框架;
- 证书双向认证永远只能把ca 或者客户端的证书给用户
Protobuf
- 语法
- 切片: repeated
- 枚举 : enum ; 比如电商获取商品时获取商品的分区;
enum ProductArea{
A=1;
B=2;
C=3;
}
3. 引入外部proto : 直接import
4. 使用TimeStamp: import "google/protobuf/timestamp.proto"
```go
message ProduInfo{
google.protobuf.TimeStamp order_time=1;
}
流模式
分为服务端流、客户端流以及双向流。
- 服务端流 :如果客户端批量查询,服务端处理比较耗时
//protobuf里面写这个
service UserVIce{
rpc GetUSerInfoByServiceStream(UserScoreRequest) returns (stream UserScoreResponse );
}
- 客户端流:如果客户端列表获取很快,服务端处理比较快
service UserVIce{
rpc GetUSerInfoByClientStream(stream UserScoreRequest) returns ( UserScoreResponse );
}
- 双向流模式:客户端和服务端处理都比较耗时
service UserVIce{
rpc GetUSerInfoByTwoWayStream(stream UserScoreRequest) returns ( stream UserScoreResponse );
}









网友评论