-
Notifications
You must be signed in to change notification settings - Fork 350
rpc
bobohume edited this page Feb 18, 2021
·
11 revisions
rpc包含服务器直接的协议加解密,具体看代码
rpc模块附上性能测试 请单元测试下 rpc的性能代码
测试性能如下:测试100万次压一个长度为25的数组
go test -v client_test.go
=== RUN TestJson //json加密
--- PASS: TestJson (1.41s)
=== RUN TestUJson //json解密
--- PASS: TestUJson (8.11s)
=== RUN TestPB //pb加密
--- PASS: TestPB (0.41s)
=== RUN TestUPB //pb解密
--- PASS: TestUPB (0.58s)
=== RUN TestRpc //rpc加密
--- PASS: TestRpc (0.62s)
=== RUN TestURpc //rpc解密
--- PASS: TestURpc (0.53s)
message RpcHead{
int64 Id = 1;//token(accountid或者playerid)
uint32 SocketId = 2;//目标socketid
uint32 SrcClusterId = 3;//源集群id
uint32 ClusterId = 4;//目标集群id
SERVICE DestServerType = 5;//目标集群
SEND SendType = 6;
string ActorName = 7;//actor名字
}
//服务器类型
enum SERVICE{
NONE= 0;
CLIENT= 1;
GATESERVER= 2;//网关,转发服务
ACCOUNTSERVER=3;//账号
WORLDSERVER=4;//世界
ZONESERVER=5;//地图
WORLDDBSERVER=6;//db
};
//发送标志
enum SEND{
POINT = 0;//指定集群id
BALANCE = 1;//负载均衡,不需要指定集群id
BOARD_CAST = 2;//广播
};
//rpc 包
message RpcPacket{
string FuncName = 1;//函数名
int32 ArgLen = 2;//参数长度
RpcHead RpcHead = 3;//rpc包头
bytes RpcBody = 4;//参数序列化
}
message ClusterInfo{
SERVICE Type = 1;//服务器类型
string Ip = 2;//局域网ip
int32 Port = 3;//端口
int32 Weight = 4;//权重(可以自行实现权重)
uint32 SocketId = 5;//socket句柄id
}