mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-24 06:34:42 +08:00
新增rpc调用数据传输数据最大长度参数配置
This commit is contained in:
@@ -14,6 +14,7 @@ var configDir = "./config/"
|
|||||||
type SetupServiceFun func(s ...service.IService)
|
type SetupServiceFun func(s ...service.IService)
|
||||||
|
|
||||||
type NodeStatus int
|
type NodeStatus int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Normal NodeStatus = 0 //正常
|
Normal NodeStatus = 0 //正常
|
||||||
Discard NodeStatus = 1 //丢弃
|
Discard NodeStatus = 1 //丢弃
|
||||||
@@ -24,6 +25,7 @@ type NodeInfo struct {
|
|||||||
NodeName string
|
NodeName string
|
||||||
Private bool
|
Private bool
|
||||||
ListenAddr string
|
ListenAddr string
|
||||||
|
MaxRpcParamLen uint32 //最大Rpc参数长度
|
||||||
ServiceList []string //所有的服务列表
|
ServiceList []string //所有的服务列表
|
||||||
PublicServiceList []string //对外公开的服务列表
|
PublicServiceList []string //对外公开的服务列表
|
||||||
DiscoveryService []string //筛选发现的服务,如果不配置,不进行筛选
|
DiscoveryService []string //筛选发现的服务,如果不配置,不进行筛选
|
||||||
@@ -37,6 +39,7 @@ type NodeRpcInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var cluster Cluster
|
var cluster Cluster
|
||||||
|
|
||||||
type Cluster struct {
|
type Cluster struct {
|
||||||
localNodeInfo NodeInfo //本结点配置信息
|
localNodeInfo NodeInfo //本结点配置信息
|
||||||
masterDiscoveryNodeList []NodeInfo //配置发现Master结点
|
masterDiscoveryNodeList []NodeInfo //配置发现Master结点
|
||||||
@@ -67,7 +70,7 @@ func SetServiceDiscovery(serviceDiscovery IServiceDiscovery) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cls *Cluster) Start() {
|
func (cls *Cluster) Start() {
|
||||||
cls.rpcServer.Start(cls.localNodeInfo.ListenAddr)
|
cls.rpcServer.Start(cls.localNodeInfo.ListenAddr, cls.localNodeInfo.MaxRpcParamLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cls *Cluster) Stop() {
|
func (cls *Cluster) Stop() {
|
||||||
@@ -150,7 +153,6 @@ func (cls *Cluster) delServiceNode(serviceName string,nodeId int){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (cls *Cluster) serviceDiscoverySetNodeInfo(nodeInfo *NodeInfo) {
|
func (cls *Cluster) serviceDiscoverySetNodeInfo(nodeInfo *NodeInfo) {
|
||||||
//本地结点不加入
|
//本地结点不加入
|
||||||
if nodeInfo.NodeId == cls.localNodeInfo.NodeId {
|
if nodeInfo.NodeId == cls.localNodeInfo.NodeId {
|
||||||
@@ -194,17 +196,16 @@ func (cls *Cluster) serviceDiscoverySetNodeInfo (nodeInfo *NodeInfo){
|
|||||||
rpcInfo.nodeInfo = *nodeInfo
|
rpcInfo.nodeInfo = *nodeInfo
|
||||||
rpcInfo.client = &rpc.Client{}
|
rpcInfo.client = &rpc.Client{}
|
||||||
rpcInfo.client.TriggerRpcEvent = cls.triggerRpcEvent
|
rpcInfo.client.TriggerRpcEvent = cls.triggerRpcEvent
|
||||||
rpcInfo.client.Connect(nodeInfo.NodeId,nodeInfo.ListenAddr)
|
rpcInfo.client.Connect(nodeInfo.NodeId, nodeInfo.ListenAddr, nodeInfo.MaxRpcParamLen)
|
||||||
cls.mapRpc[nodeInfo.NodeId] = rpcInfo
|
cls.mapRpc[nodeInfo.NodeId] = rpcInfo
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cls *Cluster) buildLocalRpc() {
|
func (cls *Cluster) buildLocalRpc() {
|
||||||
rpcInfo := NodeRpcInfo{}
|
rpcInfo := NodeRpcInfo{}
|
||||||
rpcInfo.nodeInfo = cls.localNodeInfo
|
rpcInfo.nodeInfo = cls.localNodeInfo
|
||||||
rpcInfo.client = &rpc.Client{}
|
rpcInfo.client = &rpc.Client{}
|
||||||
rpcInfo.client.Connect(rpcInfo.nodeInfo.NodeId,"")
|
rpcInfo.client.Connect(rpcInfo.nodeInfo.NodeId, "", 0)
|
||||||
|
|
||||||
cls.mapRpc[cls.localNodeInfo.NodeId] = rpcInfo
|
cls.mapRpc[cls.localNodeInfo.NodeId] = rpcInfo
|
||||||
}
|
}
|
||||||
@@ -333,7 +334,6 @@ func GetRpcClient(nodeId int,serviceMethod string,clientList []*rpc.Client) (err
|
|||||||
return nil, 1
|
return nil, 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
findIndex := strings.Index(serviceMethod, ".")
|
findIndex := strings.Index(serviceMethod, ".")
|
||||||
if findIndex == -1 {
|
if findIndex == -1 {
|
||||||
return fmt.Errorf("servicemethod param %s is error!", serviceMethod), 0
|
return fmt.Errorf("servicemethod param %s is error!", serviceMethod), 0
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ func (ds *DynamicDiscoveryMaster) OnStart() {
|
|||||||
nodeInfo.NodeName = localNodeInfo.NodeName
|
nodeInfo.NodeName = localNodeInfo.NodeName
|
||||||
nodeInfo.ListenAddr = localNodeInfo.ListenAddr
|
nodeInfo.ListenAddr = localNodeInfo.ListenAddr
|
||||||
nodeInfo.PublicServiceList = localNodeInfo.PublicServiceList
|
nodeInfo.PublicServiceList = localNodeInfo.PublicServiceList
|
||||||
|
nodeInfo.MaxRpcParamLen = localNodeInfo.MaxRpcParamLen
|
||||||
|
|
||||||
ds.addNodeInfo(&nodeInfo)
|
ds.addNodeInfo(&nodeInfo)
|
||||||
}
|
}
|
||||||
@@ -144,7 +145,7 @@ func (ds *DynamicDiscoveryMaster) RPC_RegServiceDiscover(req *rpc.ServiceDiscove
|
|||||||
nodeInfo.ServiceList = req.NodeInfo.PublicServiceList
|
nodeInfo.ServiceList = req.NodeInfo.PublicServiceList
|
||||||
nodeInfo.PublicServiceList = req.NodeInfo.PublicServiceList
|
nodeInfo.PublicServiceList = req.NodeInfo.PublicServiceList
|
||||||
nodeInfo.ListenAddr = req.NodeInfo.ListenAddr
|
nodeInfo.ListenAddr = req.NodeInfo.ListenAddr
|
||||||
|
nodeInfo.MaxRpcParamLen = req.NodeInfo.MaxRpcParamLen
|
||||||
//主动删除已经存在的结点,确保先断开,再连接
|
//主动删除已经存在的结点,确保先断开,再连接
|
||||||
cluster.serviceDiscoveryDelNode(nodeInfo.NodeId, true)
|
cluster.serviceDiscoveryDelNode(nodeInfo.NodeId, true)
|
||||||
|
|
||||||
@@ -264,6 +265,7 @@ func (dc *DynamicDiscoveryClient) RPC_SubServiceDiscover(req *rpc.SubscribeDisco
|
|||||||
nInfo.NodeId = nodeInfo.NodeId
|
nInfo.NodeId = nodeInfo.NodeId
|
||||||
nInfo.NodeName = nodeInfo.NodeName
|
nInfo.NodeName = nodeInfo.NodeName
|
||||||
nInfo.ListenAddr = nodeInfo.ListenAddr
|
nInfo.ListenAddr = nodeInfo.ListenAddr
|
||||||
|
nInfo.MaxRpcParamLen = nodeInfo.MaxRpcParamLen
|
||||||
mapNodeInfo[nodeInfo.NodeId] = nInfo
|
mapNodeInfo[nodeInfo.NodeId] = nInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,6 +326,7 @@ func (dc *DynamicDiscoveryClient) OnNodeConnected(nodeId int) {
|
|||||||
req.NodeInfo.NodeId = int32(cluster.localNodeInfo.NodeId)
|
req.NodeInfo.NodeId = int32(cluster.localNodeInfo.NodeId)
|
||||||
req.NodeInfo.NodeName = cluster.localNodeInfo.NodeName
|
req.NodeInfo.NodeName = cluster.localNodeInfo.NodeName
|
||||||
req.NodeInfo.ListenAddr = cluster.localNodeInfo.ListenAddr
|
req.NodeInfo.ListenAddr = cluster.localNodeInfo.ListenAddr
|
||||||
|
req.NodeInfo.MaxRpcParamLen = cluster.localNodeInfo.MaxRpcParamLen
|
||||||
|
|
||||||
//MasterDiscoveryNode配置中没有配置NeighborService,则同步当前结点所有服务
|
//MasterDiscoveryNode配置中没有配置NeighborService,则同步当前结点所有服务
|
||||||
if len(nodeInfo.NeighborService) == 0 {
|
if len(nodeInfo.NeighborService) == 0 {
|
||||||
@@ -373,6 +376,7 @@ func (dc *DynamicDiscoveryClient) setNodeInfo(nodeInfo *rpc.NodeInfo) {
|
|||||||
nInfo.NodeId = int(nodeInfo.NodeId)
|
nInfo.NodeId = int(nodeInfo.NodeId)
|
||||||
nInfo.NodeName = nodeInfo.NodeName
|
nInfo.NodeName = nodeInfo.NodeName
|
||||||
nInfo.ListenAddr = nodeInfo.ListenAddr
|
nInfo.ListenAddr = nodeInfo.ListenAddr
|
||||||
|
nInfo.MaxRpcParamLen = nodeInfo.MaxRpcParamLen
|
||||||
dc.funSetService(&nInfo)
|
dc.funSetService(&nInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func (client *Client) NewClientAgent(conn *network.TCPConn) network.Agent {
|
|||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (client *Client) Connect(id int,addr string) error {
|
func (client *Client) Connect(id int, addr string, maxRpcParamLen uint32) error {
|
||||||
client.clientSeq = atomic.AddUint32(&clientSeq, 1)
|
client.clientSeq = atomic.AddUint32(&clientSeq, 1)
|
||||||
client.id = id
|
client.id = id
|
||||||
client.Addr = addr
|
client.Addr = addr
|
||||||
@@ -51,9 +51,14 @@ func (client *Client) Connect(id int,addr string) error {
|
|||||||
client.ConnectInterval = time.Second * 2
|
client.ConnectInterval = time.Second * 2
|
||||||
client.PendingWriteNum = 200000
|
client.PendingWriteNum = 200000
|
||||||
client.AutoReconnect = true
|
client.AutoReconnect = true
|
||||||
client.LenMsgLen = 2
|
client.LenMsgLen = 4
|
||||||
client.MinMsgLen = 2
|
client.MinMsgLen = 2
|
||||||
client.MaxMsgLen = math.MaxUint16
|
if maxRpcParamLen > 0 {
|
||||||
|
client.MaxMsgLen = maxRpcParamLen
|
||||||
|
} else {
|
||||||
|
client.MaxMsgLen = math.MaxUint32
|
||||||
|
}
|
||||||
|
|
||||||
client.NewAgent = client.NewClientAgent
|
client.NewAgent = client.NewClientAgent
|
||||||
client.LittleEndian = LittleEndian
|
client.LittleEndian = LittleEndian
|
||||||
client.ResetPending()
|
client.ResetPending()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: rpc/dynamicdiscover.proto
|
// source: dynamicdiscover.proto
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
@@ -26,8 +26,9 @@ type NodeInfo struct {
|
|||||||
NodeId int32 `protobuf:"varint,1,opt,name=NodeId,proto3" json:"NodeId,omitempty"`
|
NodeId int32 `protobuf:"varint,1,opt,name=NodeId,proto3" json:"NodeId,omitempty"`
|
||||||
NodeName string `protobuf:"bytes,2,opt,name=NodeName,proto3" json:"NodeName,omitempty"`
|
NodeName string `protobuf:"bytes,2,opt,name=NodeName,proto3" json:"NodeName,omitempty"`
|
||||||
ListenAddr string `protobuf:"bytes,3,opt,name=ListenAddr,proto3" json:"ListenAddr,omitempty"`
|
ListenAddr string `protobuf:"bytes,3,opt,name=ListenAddr,proto3" json:"ListenAddr,omitempty"`
|
||||||
Private bool `protobuf:"varint,4,opt,name=Private,proto3" json:"Private,omitempty"`
|
MaxRpcParamLen uint32 `protobuf:"varint,4,opt,name=MaxRpcParamLen,proto3" json:"MaxRpcParamLen,omitempty"`
|
||||||
PublicServiceList []string `protobuf:"bytes,5,rep,name=PublicServiceList,proto3" json:"PublicServiceList,omitempty"`
|
Private bool `protobuf:"varint,5,opt,name=Private,proto3" json:"Private,omitempty"`
|
||||||
|
PublicServiceList []string `protobuf:"bytes,6,rep,name=PublicServiceList,proto3" json:"PublicServiceList,omitempty"`
|
||||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
XXX_unrecognized []byte `json:"-"`
|
XXX_unrecognized []byte `json:"-"`
|
||||||
XXX_sizecache int32 `json:"-"`
|
XXX_sizecache int32 `json:"-"`
|
||||||
@@ -37,7 +38,7 @@ func (m *NodeInfo) Reset() { *m = NodeInfo{} }
|
|||||||
func (m *NodeInfo) String() string { return proto.CompactTextString(m) }
|
func (m *NodeInfo) String() string { return proto.CompactTextString(m) }
|
||||||
func (*NodeInfo) ProtoMessage() {}
|
func (*NodeInfo) ProtoMessage() {}
|
||||||
func (*NodeInfo) Descriptor() ([]byte, []int) {
|
func (*NodeInfo) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_9bfdd3ec0419520f, []int{0}
|
return fileDescriptor_c41e5a852f87626c, []int{0}
|
||||||
}
|
}
|
||||||
func (m *NodeInfo) XXX_Unmarshal(b []byte) error {
|
func (m *NodeInfo) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
@@ -87,6 +88,13 @@ func (m *NodeInfo) GetListenAddr() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *NodeInfo) GetMaxRpcParamLen() uint32 {
|
||||||
|
if m != nil {
|
||||||
|
return m.MaxRpcParamLen
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func (m *NodeInfo) GetPrivate() bool {
|
func (m *NodeInfo) GetPrivate() bool {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
return m.Private
|
return m.Private
|
||||||
@@ -113,7 +121,7 @@ func (m *ServiceDiscoverReq) Reset() { *m = ServiceDiscoverReq{} }
|
|||||||
func (m *ServiceDiscoverReq) String() string { return proto.CompactTextString(m) }
|
func (m *ServiceDiscoverReq) String() string { return proto.CompactTextString(m) }
|
||||||
func (*ServiceDiscoverReq) ProtoMessage() {}
|
func (*ServiceDiscoverReq) ProtoMessage() {}
|
||||||
func (*ServiceDiscoverReq) Descriptor() ([]byte, []int) {
|
func (*ServiceDiscoverReq) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_9bfdd3ec0419520f, []int{1}
|
return fileDescriptor_c41e5a852f87626c, []int{1}
|
||||||
}
|
}
|
||||||
func (m *ServiceDiscoverReq) XXX_Unmarshal(b []byte) error {
|
func (m *ServiceDiscoverReq) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
@@ -164,7 +172,7 @@ func (m *SubscribeDiscoverNotify) Reset() { *m = SubscribeDiscoverNotify
|
|||||||
func (m *SubscribeDiscoverNotify) String() string { return proto.CompactTextString(m) }
|
func (m *SubscribeDiscoverNotify) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SubscribeDiscoverNotify) ProtoMessage() {}
|
func (*SubscribeDiscoverNotify) ProtoMessage() {}
|
||||||
func (*SubscribeDiscoverNotify) Descriptor() ([]byte, []int) {
|
func (*SubscribeDiscoverNotify) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_9bfdd3ec0419520f, []int{2}
|
return fileDescriptor_c41e5a852f87626c, []int{2}
|
||||||
}
|
}
|
||||||
func (m *SubscribeDiscoverNotify) XXX_Unmarshal(b []byte) error {
|
func (m *SubscribeDiscoverNotify) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
@@ -232,7 +240,7 @@ func (m *Empty) Reset() { *m = Empty{} }
|
|||||||
func (m *Empty) String() string { return proto.CompactTextString(m) }
|
func (m *Empty) String() string { return proto.CompactTextString(m) }
|
||||||
func (*Empty) ProtoMessage() {}
|
func (*Empty) ProtoMessage() {}
|
||||||
func (*Empty) Descriptor() ([]byte, []int) {
|
func (*Empty) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_9bfdd3ec0419520f, []int{3}
|
return fileDescriptor_c41e5a852f87626c, []int{3}
|
||||||
}
|
}
|
||||||
func (m *Empty) XXX_Unmarshal(b []byte) error {
|
func (m *Empty) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
@@ -268,30 +276,31 @@ func init() {
|
|||||||
proto.RegisterType((*Empty)(nil), "rpc.Empty")
|
proto.RegisterType((*Empty)(nil), "rpc.Empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("rpc/dynamicdiscover.proto", fileDescriptor_9bfdd3ec0419520f) }
|
func init() { proto.RegisterFile("dynamicdiscover.proto", fileDescriptor_c41e5a852f87626c) }
|
||||||
|
|
||||||
var fileDescriptor_9bfdd3ec0419520f = []byte{
|
var fileDescriptor_c41e5a852f87626c = []byte{
|
||||||
// 305 bytes of a gzipped FileDescriptorProto
|
// 324 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xd1, 0x4a, 0xc3, 0x30,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xdf, 0x4a, 0xc3, 0x30,
|
||||||
0x18, 0x85, 0x89, 0x5d, 0xb7, 0xee, 0x57, 0x2f, 0x8c, 0xa0, 0x51, 0xa4, 0x94, 0x5e, 0x55, 0x90,
|
0x14, 0xc6, 0x89, 0x5d, 0xb7, 0xee, 0xe8, 0x04, 0x23, 0x6a, 0x10, 0x29, 0xa5, 0x17, 0x52, 0x41,
|
||||||
0x0e, 0xf4, 0x01, 0x44, 0x99, 0xc2, 0x40, 0xc7, 0xc8, 0xee, 0xbc, 0x6b, 0x93, 0x0c, 0x02, 0x5d,
|
0x2a, 0xe8, 0x03, 0x88, 0x32, 0x85, 0xc1, 0x36, 0x46, 0x76, 0xe7, 0x5d, 0x9a, 0x66, 0x10, 0xe8,
|
||||||
0x13, 0xd3, 0x6c, 0xb0, 0x97, 0xf1, 0xd2, 0x67, 0xf1, 0xd2, 0x47, 0x90, 0x3d, 0x89, 0x2c, 0x66,
|
0x3f, 0xd3, 0x6c, 0xb8, 0x97, 0xf1, 0x79, 0xbc, 0x12, 0x1f, 0x41, 0xf6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, 0x58, 0x6a, 0x39,
|
||||||
0xaa, 0xdc, 0x0a, 0x22, 0xea, 0x09, 0x5f, 0x40, 0xb7, 0x2f, 0x2a, 0x6f, 0x0c, 0x9c, 0xf1, 0x77,
|
0x99, 0xe3, 0x10, 0xf6, 0x06, 0xac, 0xd6, 0x4b, 0xde, 0xa8, 0x69, 0x4b, 0x5b, 0x96, 0xd8, 0xab,
|
||||||
0xb0, 0x13, 0xb0, 0x95, 0x04, 0xff, 0x05, 0xec, 0x40, 0xf8, 0x30, 0xd5, 0x76, 0x71, 0x7f, 0xfc,
|
0x1f, 0xa7, 0x59, 0x66, 0xaa, 0xf2, 0xa8, 0x25, 0x7c, 0x06, 0xed, 0xae, 0xc8, 0xec, 0xa0, 0x63,
|
||||||
0xb1, 0x8c, 0xd1, 0xe7, 0x32, 0x46, 0x5f, 0xcb, 0x18, 0xbd, 0x84, 0x79, 0xcf, 0x68, 0x56, 0xb6,
|
0x06, 0x7f, 0x84, 0xad, 0x03, 0x1b, 0x81, 0xf3, 0xdf, 0x81, 0x2d, 0x70, 0x1f, 0xf2, 0x4a, 0xcf,
|
||||||
0xdd, 0xa7, 0xdd, 0x7c, 0x07, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x79, 0x82, 0x2a, 0xd1, 0x01, 0x00,
|
0xef, 0x0f, 0xdf, 0x16, 0x3e, 0xfa, 0x58, 0xf8, 0xe8, 0x73, 0xe1, 0xa3, 0x27, 0x37, 0xbe, 0x52,
|
||||||
0x00,
|
0x15, 0x4f, 0x9a, 0xe6, 0x71, 0x6f, 0xbe, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xfb, 0xa9, 0x70,
|
||||||
|
0xf5, 0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *NodeInfo) Marshal() (dAtA []byte, err error) {
|
func (m *NodeInfo) Marshal() (dAtA []byte, err error) {
|
||||||
@@ -324,7 +333,7 @@ func (m *NodeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
copy(dAtA[i:], m.PublicServiceList[iNdEx])
|
copy(dAtA[i:], m.PublicServiceList[iNdEx])
|
||||||
i = encodeVarintDynamicdiscover(dAtA, i, uint64(len(m.PublicServiceList[iNdEx])))
|
i = encodeVarintDynamicdiscover(dAtA, i, uint64(len(m.PublicServiceList[iNdEx])))
|
||||||
i--
|
i--
|
||||||
dAtA[i] = 0x2a
|
dAtA[i] = 0x32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if m.Private {
|
if m.Private {
|
||||||
@@ -335,6 +344,11 @@ func (m *NodeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||||||
dAtA[i] = 0
|
dAtA[i] = 0
|
||||||
}
|
}
|
||||||
i--
|
i--
|
||||||
|
dAtA[i] = 0x28
|
||||||
|
}
|
||||||
|
if m.MaxRpcParamLen != 0 {
|
||||||
|
i = encodeVarintDynamicdiscover(dAtA, i, uint64(m.MaxRpcParamLen))
|
||||||
|
i--
|
||||||
dAtA[i] = 0x20
|
dAtA[i] = 0x20
|
||||||
}
|
}
|
||||||
if len(m.ListenAddr) > 0 {
|
if len(m.ListenAddr) > 0 {
|
||||||
@@ -514,6 +528,9 @@ func (m *NodeInfo) Size() (n int) {
|
|||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sovDynamicdiscover(uint64(l))
|
n += 1 + l + sovDynamicdiscover(uint64(l))
|
||||||
}
|
}
|
||||||
|
if m.MaxRpcParamLen != 0 {
|
||||||
|
n += 1 + sovDynamicdiscover(uint64(m.MaxRpcParamLen))
|
||||||
|
}
|
||||||
if m.Private {
|
if m.Private {
|
||||||
n += 2
|
n += 2
|
||||||
}
|
}
|
||||||
@@ -703,6 +720,25 @@ func (m *NodeInfo) Unmarshal(dAtA []byte) error {
|
|||||||
m.ListenAddr = string(dAtA[iNdEx:postIndex])
|
m.ListenAddr = string(dAtA[iNdEx:postIndex])
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
case 4:
|
case 4:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field MaxRpcParamLen", wireType)
|
||||||
|
}
|
||||||
|
m.MaxRpcParamLen = 0
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowDynamicdiscover
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
m.MaxRpcParamLen |= uint32(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 5:
|
||||||
if wireType != 0 {
|
if wireType != 0 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field Private", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field Private", wireType)
|
||||||
}
|
}
|
||||||
@@ -722,7 +758,7 @@ func (m *NodeInfo) Unmarshal(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.Private = bool(v != 0)
|
m.Private = bool(v != 0)
|
||||||
case 5:
|
case 6:
|
||||||
if wireType != 2 {
|
if wireType != 2 {
|
||||||
return fmt.Errorf("proto: wrong wireType = %d for field PublicServiceList", wireType)
|
return fmt.Errorf("proto: wrong wireType = %d for field PublicServiceList", wireType)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ message NodeInfo{
|
|||||||
int32 NodeId = 1;
|
int32 NodeId = 1;
|
||||||
string NodeName = 2;
|
string NodeName = 2;
|
||||||
string ListenAddr = 3;
|
string ListenAddr = 3;
|
||||||
bool Private = 4;
|
uint32 MaxRpcParamLen = 4;
|
||||||
repeated string PublicServiceList = 5;
|
bool Private = 5;
|
||||||
|
repeated string PublicServiceList = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Client->Master
|
//Client->Master
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||||
// source: rpc/gogorpc.proto
|
// source: gogorpc.proto
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ func (m *GoGoPBRpcRequestData) Reset() { *m = GoGoPBRpcRequestData{} }
|
|||||||
func (m *GoGoPBRpcRequestData) String() string { return proto.CompactTextString(m) }
|
func (m *GoGoPBRpcRequestData) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GoGoPBRpcRequestData) ProtoMessage() {}
|
func (*GoGoPBRpcRequestData) ProtoMessage() {}
|
||||||
func (*GoGoPBRpcRequestData) Descriptor() ([]byte, []int) {
|
func (*GoGoPBRpcRequestData) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_38afb24c36168563, []int{0}
|
return fileDescriptor_d0e25d3af112ec8f, []int{0}
|
||||||
}
|
}
|
||||||
func (m *GoGoPBRpcRequestData) XXX_Unmarshal(b []byte) error {
|
func (m *GoGoPBRpcRequestData) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
@@ -114,7 +114,7 @@ func (m *GoGoPBRpcResponseData) Reset() { *m = GoGoPBRpcResponseData{} }
|
|||||||
func (m *GoGoPBRpcResponseData) String() string { return proto.CompactTextString(m) }
|
func (m *GoGoPBRpcResponseData) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GoGoPBRpcResponseData) ProtoMessage() {}
|
func (*GoGoPBRpcResponseData) ProtoMessage() {}
|
||||||
func (*GoGoPBRpcResponseData) Descriptor() ([]byte, []int) {
|
func (*GoGoPBRpcResponseData) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_38afb24c36168563, []int{1}
|
return fileDescriptor_d0e25d3af112ec8f, []int{1}
|
||||||
}
|
}
|
||||||
func (m *GoGoPBRpcResponseData) XXX_Unmarshal(b []byte) error {
|
func (m *GoGoPBRpcResponseData) XXX_Unmarshal(b []byte) error {
|
||||||
return m.Unmarshal(b)
|
return m.Unmarshal(b)
|
||||||
@@ -169,25 +169,25 @@ func init() {
|
|||||||
proto.RegisterType((*GoGoPBRpcResponseData)(nil), "rpc.GoGoPBRpcResponseData")
|
proto.RegisterType((*GoGoPBRpcResponseData)(nil), "rpc.GoGoPBRpcResponseData")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("rpc/gogorpc.proto", fileDescriptor_38afb24c36168563) }
|
func init() { proto.RegisterFile("gogorpc.proto", fileDescriptor_d0e25d3af112ec8f) }
|
||||||
|
|
||||||
var fileDescriptor_38afb24c36168563 = []byte{
|
var fileDescriptor_d0e25d3af112ec8f = []byte{
|
||||||
// 237 bytes of a gzipped FileDescriptorProto
|
// 233 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x2a, 0x48, 0xd6,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0xcf, 0x4f, 0xcf,
|
||||||
0x4f, 0xcf, 0x4f, 0xcf, 0x2f, 0x2a, 0x48, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2e,
|
0x2f, 0x2a, 0x48, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2e, 0x2a, 0x48, 0x56, 0x5a,
|
||||||
0x2a, 0x48, 0x56, 0x5a, 0xc2, 0xc8, 0x25, 0xe2, 0x9e, 0xef, 0x9e, 0x1f, 0xe0, 0x14, 0x54, 0x90,
|
0xc2, 0xc8, 0x25, 0xe2, 0x9e, 0xef, 0x9e, 0x1f, 0xe0, 0x14, 0x54, 0x90, 0x1c, 0x94, 0x5a, 0x58,
|
||||||
0x1c, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0xe2, 0x92, 0x58, 0x92, 0x28, 0x24, 0xc0, 0xc5, 0x1c,
|
0x9a, 0x5a, 0x5c, 0xe2, 0x92, 0x58, 0x92, 0x28, 0x24, 0xc0, 0xc5, 0x1c, 0x9c, 0x5a, 0x28, 0xc1,
|
||||||
0x9c, 0x5a, 0x28, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x12, 0x04, 0x62, 0x0a, 0x29, 0x70, 0x71, 0x07,
|
0xa8, 0xc0, 0xa8, 0xc1, 0x12, 0x04, 0x62, 0x0a, 0x29, 0x70, 0x71, 0x07, 0x15, 0x24, 0xfb, 0xa6,
|
||||||
0x15, 0x24, 0xfb, 0xa6, 0x96, 0x64, 0xe4, 0xa7, 0x78, 0xa6, 0x48, 0x30, 0x29, 0x30, 0x6a, 0xf0,
|
0x96, 0x64, 0xe4, 0xa7, 0x78, 0xa6, 0x48, 0x30, 0x29, 0x30, 0x6a, 0xf0, 0x06, 0x21, 0x0b, 0x09,
|
||||||
0x06, 0x21, 0x0b, 0x09, 0xa9, 0x70, 0xf1, 0x06, 0xa7, 0x16, 0x95, 0x65, 0x26, 0xa7, 0x42, 0x84,
|
0xa9, 0x70, 0xf1, 0x06, 0xa7, 0x16, 0x95, 0x65, 0x26, 0xa7, 0x42, 0x84, 0x24, 0x98, 0x15, 0x18,
|
||||||
0x24, 0x98, 0x15, 0x18, 0x35, 0x38, 0x83, 0x50, 0x05, 0x85, 0x24, 0xb8, 0xd8, 0xfd, 0xf2, 0x83,
|
0x35, 0x38, 0x83, 0x50, 0x05, 0x85, 0x24, 0xb8, 0xd8, 0xfd, 0xf2, 0x83, 0x52, 0x0b, 0x72, 0x2a,
|
||||||
0x52, 0x0b, 0x72, 0x2a, 0x25, 0x58, 0x14, 0x18, 0x35, 0x38, 0x82, 0x60, 0x5c, 0x90, 0x8c, 0x67,
|
0x25, 0x58, 0x14, 0x18, 0x35, 0x38, 0x82, 0x60, 0x5c, 0x90, 0x8c, 0x67, 0x5e, 0x40, 0x62, 0x51,
|
||||||
0x5e, 0x40, 0x62, 0x51, 0x62, 0xae, 0x04, 0xab, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x8c, 0xab, 0x14,
|
0x62, 0xae, 0x04, 0xab, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x8c, 0xab, 0x14, 0xca, 0x25, 0x8a, 0xe4,
|
||||||
0xca, 0x25, 0x8a, 0xe4, 0xca, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x1c, 0xce, 0x14, 0xe1, 0x62,
|
0xca, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x1c, 0xce, 0x14, 0xe1, 0x62, 0x75, 0x2d, 0x2a, 0xca,
|
||||||
0x75, 0x2d, 0x2a, 0xca, 0x2f, 0x02, 0x3b, 0x90, 0x33, 0x08, 0xc2, 0x01, 0x89, 0x42, 0xac, 0x64,
|
0x2f, 0x02, 0x3b, 0x90, 0x33, 0x08, 0xc2, 0x01, 0x89, 0x42, 0xac, 0x64, 0x06, 0x1b, 0x0c, 0xe1,
|
||||||
0x06, 0x1b, 0x0c, 0xe1, 0x38, 0x09, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83,
|
0x38, 0x09, 0x9f, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x51,
|
||||||
0x47, 0x72, 0x8c, 0x51, 0xac, 0x7a, 0xfa, 0x45, 0x05, 0xc9, 0x49, 0x6c, 0xe0, 0xe0, 0x31, 0x06,
|
0xac, 0x7a, 0xfa, 0x45, 0x05, 0xc9, 0x49, 0x6c, 0xe0, 0xe0, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff,
|
||||||
0x04, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xfc, 0x50, 0x87, 0x33, 0x01, 0x00, 0x00,
|
0xff, 0x26, 0xcf, 0x31, 0x39, 0x2f, 0x01, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GoGoPBRpcRequestData) Marshal() (dAtA []byte, err error) {
|
func (m *GoGoPBRpcRequestData) Marshal() (dAtA []byte, err error) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RpcProcessorType uint8
|
type RpcProcessorType uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -61,16 +62,21 @@ func (server *Server) Init(rpcHandleFinder RpcHandleFinder) {
|
|||||||
server.rpcServer = &network.TCPServer{}
|
server.rpcServer = &network.TCPServer{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) Start(listenAddr string) {
|
func (server *Server) Start(listenAddr string, maxRpcParamLen uint32) {
|
||||||
splitAddr := strings.Split(listenAddr, ":")
|
splitAddr := strings.Split(listenAddr, ":")
|
||||||
if len(splitAddr) != 2 {
|
if len(splitAddr) != 2 {
|
||||||
log.SFatal("listen addr is error :", listenAddr)
|
log.SFatal("listen addr is error :", listenAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
server.rpcServer.Addr = ":" + splitAddr[1]
|
server.rpcServer.Addr = ":" + splitAddr[1]
|
||||||
server.rpcServer.LenMsgLen = 2 //uint16
|
server.rpcServer.LenMsgLen = 4 //uint16
|
||||||
server.rpcServer.MinMsgLen = 2
|
server.rpcServer.MinMsgLen = 2
|
||||||
server.rpcServer.MaxMsgLen = math.MaxUint16
|
if maxRpcParamLen > 0 {
|
||||||
|
server.rpcServer.MaxMsgLen = maxRpcParamLen
|
||||||
|
} else {
|
||||||
|
server.rpcServer.MaxMsgLen = math.MaxUint32
|
||||||
|
}
|
||||||
|
|
||||||
server.rpcServer.MaxConnNum = 10000
|
server.rpcServer.MaxConnNum = 10000
|
||||||
server.rpcServer.PendingWriteNum = 2000000
|
server.rpcServer.PendingWriteNum = 2000000
|
||||||
server.rpcServer.NewAgent = server.NewAgent
|
server.rpcServer.NewAgent = server.NewAgent
|
||||||
@@ -238,7 +244,6 @@ func (server *Server) myselfRpcHandlerGo(handlerName string,serviceMethod string
|
|||||||
return rpcHandler.CallMethod(serviceMethod, args, reply)
|
return rpcHandler.CallMethod(serviceMethod, args, reply)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor, client *Client, noReply bool, handlerName string, rpcMethodId uint32, serviceMethod string, args interface{}, reply interface{}, rawArgs []byte) *Call {
|
func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor, client *Client, noReply bool, handlerName string, rpcMethodId uint32, serviceMethod string, args interface{}, reply interface{}, rawArgs []byte) *Call {
|
||||||
pCall := MakeCall()
|
pCall := MakeCall()
|
||||||
pCall.Seq = client.generateSeq()
|
pCall.Seq = client.generateSeq()
|
||||||
|
|||||||
Reference in New Issue
Block a user