mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-12 22:54:43 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78cc33c84e | ||
|
|
9cf21bf418 | ||
|
|
c6d0bd9a19 | ||
|
|
61bf95e457 | ||
|
|
8b2a551ee5 | ||
|
|
927c2ffa37 | ||
|
|
b23b30aac5 |
@@ -62,6 +62,7 @@ type Cluster struct {
|
|||||||
locker sync.RWMutex //结点与服务关系保护锁
|
locker sync.RWMutex //结点与服务关系保护锁
|
||||||
mapRpc map[string]*NodeRpcInfo //nodeId
|
mapRpc map[string]*NodeRpcInfo //nodeId
|
||||||
mapServiceNode map[string]map[string]struct{} //map[serviceName]map[NodeId]
|
mapServiceNode map[string]map[string]struct{} //map[serviceName]map[NodeId]
|
||||||
|
mapTemplateServiceNode map[string]map[string]struct{} //map[templateServiceName]map[serviceName]nodeId
|
||||||
|
|
||||||
callSet rpc.CallSet
|
callSet rpc.CallSet
|
||||||
rpcNats rpc.RpcNats
|
rpcNats rpc.RpcNats
|
||||||
@@ -137,6 +138,20 @@ func (cls *Cluster) delServiceNode(serviceName string, nodeId string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//处理模板服务
|
||||||
|
splitServiceName := strings.Split(serviceName,":")
|
||||||
|
if len(splitServiceName) == 2 {
|
||||||
|
serviceName = splitServiceName[0]
|
||||||
|
templateServiceName := splitServiceName[1]
|
||||||
|
|
||||||
|
mapService := cls.mapTemplateServiceNode[templateServiceName]
|
||||||
|
delete(mapService,serviceName)
|
||||||
|
|
||||||
|
if len(cls.mapTemplateServiceNode[templateServiceName]) == 0 {
|
||||||
|
delete(cls.mapTemplateServiceNode,templateServiceName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mapNode := cls.mapServiceNode[serviceName]
|
mapNode := cls.mapServiceNode[serviceName]
|
||||||
delete(mapNode, nodeId)
|
delete(mapNode, nodeId)
|
||||||
if len(mapNode) == 0 {
|
if len(mapNode) == 0 {
|
||||||
@@ -171,7 +186,20 @@ func (cls *Cluster) serviceDiscoverySetNodeInfo(nodeInfo *NodeInfo) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
mapDuplicate[serviceName] = nil
|
mapDuplicate[serviceName] = nil
|
||||||
if _, ok := cls.mapServiceNode[serviceName]; ok == false {
|
|
||||||
|
//如果是模板服务,则记录模板关系
|
||||||
|
splitServiceName := strings.Split(serviceName,":")
|
||||||
|
if len(splitServiceName) == 2 {
|
||||||
|
serviceName = splitServiceName[0]
|
||||||
|
templateServiceName := splitServiceName[1]
|
||||||
|
//记录模板
|
||||||
|
if _, ok = cls.mapTemplateServiceNode[templateServiceName]; ok == false {
|
||||||
|
cls.mapTemplateServiceNode[templateServiceName]=map[string]struct{}{}
|
||||||
|
}
|
||||||
|
cls.mapTemplateServiceNode[templateServiceName][serviceName] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok = cls.mapServiceNode[serviceName]; ok == false {
|
||||||
cls.mapServiceNode[serviceName] = make(map[string]struct{}, 1)
|
cls.mapServiceNode[serviceName] = make(map[string]struct{}, 1)
|
||||||
}
|
}
|
||||||
cls.mapServiceNode[serviceName][nodeInfo.NodeId] = struct{}{}
|
cls.mapServiceNode[serviceName][nodeInfo.NodeId] = struct{}{}
|
||||||
@@ -259,25 +287,29 @@ func (cls *Cluster) GetRpcClient(nodeId string) (*rpc.Client,bool) {
|
|||||||
return cls.getRpcClient(nodeId)
|
return cls.getRpcClient(nodeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRpcClient(nodeId string, serviceMethod string,filterRetire bool, clientList []*rpc.Client) (error, int) {
|
func GetNodeIdByTemplateService(templateServiceName string, rpcClientList []*rpc.Client, filterRetire bool) (error, []*rpc.Client) {
|
||||||
|
return GetCluster().GetNodeIdByTemplateService(templateServiceName, rpcClientList, filterRetire)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetRpcClient(nodeId string, serviceMethod string,filterRetire bool, clientList []*rpc.Client) (error, []*rpc.Client) {
|
||||||
if nodeId != rpc.NodeIdNull {
|
if nodeId != rpc.NodeIdNull {
|
||||||
pClient,retire := GetCluster().GetRpcClient(nodeId)
|
pClient,retire := GetCluster().GetRpcClient(nodeId)
|
||||||
if pClient == nil {
|
if pClient == nil {
|
||||||
return fmt.Errorf("cannot find nodeid %d!", nodeId), 0
|
return fmt.Errorf("cannot find nodeid %d!", nodeId), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//如果需要筛选掉退休结点
|
//如果需要筛选掉退休结点
|
||||||
if filterRetire == true && retire == true {
|
if filterRetire == true && retire == true {
|
||||||
return fmt.Errorf("cannot find nodeid %d!", nodeId), 0
|
return fmt.Errorf("cannot find nodeid %d!", nodeId), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
clientList[0] = pClient
|
clientList = append(clientList,pClient)
|
||||||
return nil, 1
|
return nil, clientList
|
||||||
}
|
}
|
||||||
|
|
||||||
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), nil
|
||||||
}
|
}
|
||||||
serviceName := serviceMethod[:findIndex]
|
serviceName := serviceMethod[:findIndex]
|
||||||
|
|
||||||
@@ -376,6 +408,27 @@ func GetNodeByServiceName(serviceName string) map[string]struct{} {
|
|||||||
return mapNodeId
|
return mapNodeId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetNodeByTemplateServiceName 通过模板服务名获取服务名,返回 map[serviceName真实服务名]NodeId
|
||||||
|
func GetNodeByTemplateServiceName(templateServiceName string) map[string]string {
|
||||||
|
cluster.locker.RLock()
|
||||||
|
defer cluster.locker.RUnlock()
|
||||||
|
|
||||||
|
mapServiceName := cluster.mapTemplateServiceNode[templateServiceName]
|
||||||
|
mapNodeId := make(map[string]string,9)
|
||||||
|
for serviceName := range mapServiceName {
|
||||||
|
mapNode, ok := cluster.mapServiceNode[serviceName]
|
||||||
|
if ok == false {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for nodeId,_ := range mapNode {
|
||||||
|
mapNodeId[serviceName] = nodeId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mapNodeId
|
||||||
|
}
|
||||||
|
|
||||||
func (cls *Cluster) GetGlobalCfg() interface{} {
|
func (cls *Cluster) GetGlobalCfg() interface{} {
|
||||||
return cls.globalCfg
|
return cls.globalCfg
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,10 @@ func (ds *OriginDiscoveryMaster) OnNodeDisconnect(nodeId string) {
|
|||||||
|
|
||||||
func (ds *OriginDiscoveryMaster) RpcCastGo(serviceMethod string, args interface{}) {
|
func (ds *OriginDiscoveryMaster) RpcCastGo(serviceMethod string, args interface{}) {
|
||||||
for nodeId, _ := range ds.mapNodeInfo {
|
for nodeId, _ := range ds.mapNodeInfo {
|
||||||
|
if nodeId == cluster.GetLocalNodeInfo().NodeId {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
ds.GoNode(nodeId, serviceMethod, args)
|
ds.GoNode(nodeId, serviceMethod, args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ func (cls *Cluster) readLocalClusterConfig(nodeId string) (DiscoveryInfo, []Node
|
|||||||
}
|
}
|
||||||
|
|
||||||
if nodeId != rpc.NodeIdNull && (len(nodeInfoList) != 1) {
|
if nodeId != rpc.NodeIdNull && (len(nodeInfoList) != 1) {
|
||||||
return discoveryInfo, nil,rpcMode, fmt.Errorf("%d configurations were found for the configuration with node ID %d!", len(nodeInfoList), nodeId)
|
return discoveryInfo, nil,rpcMode, fmt.Errorf("nodeid %s configuration error in NodeList", nodeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, _ := range nodeInfoList {
|
for i, _ := range nodeInfoList {
|
||||||
@@ -325,6 +325,10 @@ func (cls *Cluster) readLocalService(localNodeId string) error {
|
|||||||
//保存公共配置
|
//保存公共配置
|
||||||
for _, s := range cls.localNodeInfo.ServiceList {
|
for _, s := range cls.localNodeInfo.ServiceList {
|
||||||
for {
|
for {
|
||||||
|
splitServiceName := strings.Split(s,":")
|
||||||
|
if len(splitServiceName) == 2 {
|
||||||
|
s = splitServiceName[0]
|
||||||
|
}
|
||||||
//取公共服务配置
|
//取公共服务配置
|
||||||
pubCfg, ok := serviceConfig[s]
|
pubCfg, ok := serviceConfig[s]
|
||||||
if ok == true {
|
if ok == true {
|
||||||
@@ -355,6 +359,11 @@ func (cls *Cluster) readLocalService(localNodeId string) error {
|
|||||||
|
|
||||||
//组合所有的配置
|
//组合所有的配置
|
||||||
for _, s := range cls.localNodeInfo.ServiceList {
|
for _, s := range cls.localNodeInfo.ServiceList {
|
||||||
|
splitServiceName := strings.Split(s,":")
|
||||||
|
if len(splitServiceName) == 2 {
|
||||||
|
s = splitServiceName[0]
|
||||||
|
}
|
||||||
|
|
||||||
//先从NodeService中找
|
//先从NodeService中找
|
||||||
var serviceCfg interface{}
|
var serviceCfg interface{}
|
||||||
var ok bool
|
var ok bool
|
||||||
@@ -382,12 +391,24 @@ func (cls *Cluster) parseLocalCfg() {
|
|||||||
|
|
||||||
cls.mapRpc[cls.localNodeInfo.NodeId] = &rpcInfo
|
cls.mapRpc[cls.localNodeInfo.NodeId] = &rpcInfo
|
||||||
|
|
||||||
for _, sName := range cls.localNodeInfo.ServiceList {
|
for _, serviceName := range cls.localNodeInfo.ServiceList {
|
||||||
if _, ok := cls.mapServiceNode[sName]; ok == false {
|
splitServiceName := strings.Split(serviceName,":")
|
||||||
cls.mapServiceNode[sName] = make(map[string]struct{})
|
if len(splitServiceName) == 2 {
|
||||||
|
serviceName = splitServiceName[0]
|
||||||
|
templateServiceName := splitServiceName[1]
|
||||||
|
//记录模板
|
||||||
|
if _, ok := cls.mapTemplateServiceNode[templateServiceName]; ok == false {
|
||||||
|
cls.mapTemplateServiceNode[templateServiceName]=map[string]struct{}{}
|
||||||
|
}
|
||||||
|
cls.mapTemplateServiceNode[templateServiceName][serviceName] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
cls.mapServiceNode[sName][cls.localNodeInfo.NodeId] = struct{}{}
|
|
||||||
|
if _, ok := cls.mapServiceNode[serviceName]; ok == false {
|
||||||
|
cls.mapServiceNode[serviceName] = make(map[string]struct{})
|
||||||
|
}
|
||||||
|
|
||||||
|
cls.mapServiceNode[serviceName][cls.localNodeInfo.NodeId] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,6 +424,7 @@ func (cls *Cluster) InitCfg(localNodeId string) error {
|
|||||||
cls.localServiceCfg = map[string]interface{}{}
|
cls.localServiceCfg = map[string]interface{}{}
|
||||||
cls.mapRpc = map[string]*NodeRpcInfo{}
|
cls.mapRpc = map[string]*NodeRpcInfo{}
|
||||||
cls.mapServiceNode = map[string]map[string]struct{}{}
|
cls.mapServiceNode = map[string]map[string]struct{}{}
|
||||||
|
cls.mapTemplateServiceNode = map[string]map[string]struct{}{}
|
||||||
|
|
||||||
//加载本地结点的NodeList配置
|
//加载本地结点的NodeList配置
|
||||||
discoveryInfo, nodeInfoList,rpcMode, err := cls.readLocalClusterConfig(localNodeId)
|
discoveryInfo, nodeInfoList,rpcMode, err := cls.readLocalClusterConfig(localNodeId)
|
||||||
@@ -436,12 +458,37 @@ func (cls *Cluster) IsConfigService(serviceName string) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cls *Cluster) GetNodeIdByTemplateService(templateServiceName string, rpcClientList []*rpc.Client, filterRetire bool) (error, []*rpc.Client) {
|
||||||
|
cls.locker.RLock()
|
||||||
|
defer cls.locker.RUnlock()
|
||||||
|
|
||||||
func (cls *Cluster) GetNodeIdByService(serviceName string, rpcClientList []*rpc.Client, filterRetire bool) (error, int) {
|
mapServiceName := cls.mapTemplateServiceNode[templateServiceName]
|
||||||
|
for serviceName := range mapServiceName {
|
||||||
|
mapNodeId, ok := cls.mapServiceNode[serviceName]
|
||||||
|
if ok == true {
|
||||||
|
for nodeId, _ := range mapNodeId {
|
||||||
|
pClient,retire := GetCluster().getRpcClient(nodeId)
|
||||||
|
if pClient == nil || pClient.IsConnected() == false {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
//如果需要筛选掉退休的,对retire状态的结点略过
|
||||||
|
if filterRetire == true && retire == true {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcClientList = append(rpcClientList,pClient)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, rpcClientList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cls *Cluster) GetNodeIdByService(serviceName string, rpcClientList []*rpc.Client, filterRetire bool) (error, []*rpc.Client) {
|
||||||
cls.locker.RLock()
|
cls.locker.RLock()
|
||||||
defer cls.locker.RUnlock()
|
defer cls.locker.RUnlock()
|
||||||
mapNodeId, ok := cls.mapServiceNode[serviceName]
|
mapNodeId, ok := cls.mapServiceNode[serviceName]
|
||||||
count := 0
|
|
||||||
if ok == true {
|
if ok == true {
|
||||||
for nodeId, _ := range mapNodeId {
|
for nodeId, _ := range mapNodeId {
|
||||||
pClient,retire := GetCluster().getRpcClient(nodeId)
|
pClient,retire := GetCluster().getRpcClient(nodeId)
|
||||||
@@ -454,15 +501,11 @@ func (cls *Cluster) GetNodeIdByService(serviceName string, rpcClientList []*rpc.
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcClientList[count] = pClient
|
rpcClientList = append(rpcClientList,pClient)
|
||||||
count++
|
|
||||||
if count >= cap(rpcClientList) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, count
|
return nil, rpcClientList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cls *Cluster) GetServiceCfg(serviceName string) interface{} {
|
func (cls *Cluster) GetServiceCfg(serviceName string) interface{} {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const (
|
|||||||
Sys_Event_QueueTaskFinish EventType = -10
|
Sys_Event_QueueTaskFinish EventType = -10
|
||||||
Sys_Event_Retire EventType = -11
|
Sys_Event_Retire EventType = -11
|
||||||
Sys_Event_EtcdDiscovery EventType = -12
|
Sys_Event_EtcdDiscovery EventType = -12
|
||||||
|
Sys_Event_Gin_Event EventType = -13
|
||||||
|
|
||||||
Sys_Event_User_Define EventType = 1
|
Sys_Event_User_Define EventType = 1
|
||||||
)
|
)
|
||||||
|
|||||||
32
node/node.go
32
node/node.go
@@ -25,6 +25,7 @@ import (
|
|||||||
var sig chan os.Signal
|
var sig chan os.Signal
|
||||||
var nodeId string
|
var nodeId string
|
||||||
var preSetupService []service.IService //预安装
|
var preSetupService []service.IService //预安装
|
||||||
|
var preSetupTemplateService []func()service.IService
|
||||||
var profilerInterval time.Duration
|
var profilerInterval time.Duration
|
||||||
var bValid bool
|
var bValid bool
|
||||||
var configDir = "./config/"
|
var configDir = "./config/"
|
||||||
@@ -169,6 +170,31 @@ func initNode(id string) {
|
|||||||
serviceOrder := cluster.GetCluster().GetLocalNodeInfo().ServiceList
|
serviceOrder := cluster.GetCluster().GetLocalNodeInfo().ServiceList
|
||||||
for _,serviceName:= range serviceOrder{
|
for _,serviceName:= range serviceOrder{
|
||||||
bSetup := false
|
bSetup := false
|
||||||
|
|
||||||
|
//判断是否有配置模板服务
|
||||||
|
splitServiceName := strings.Split(serviceName,":")
|
||||||
|
if len(splitServiceName) == 2 {
|
||||||
|
serviceName = splitServiceName[0]
|
||||||
|
templateServiceName := splitServiceName[1]
|
||||||
|
for _,newSer := range preSetupTemplateService {
|
||||||
|
ser := newSer()
|
||||||
|
ser.OnSetup(ser)
|
||||||
|
if ser.GetName() == templateServiceName {
|
||||||
|
ser.SetName(serviceName)
|
||||||
|
ser.Init(ser,cluster.GetRpcClient,cluster.GetRpcServer,cluster.GetCluster().GetServiceCfg(ser.GetName()))
|
||||||
|
service.Setup(ser)
|
||||||
|
|
||||||
|
bSetup = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if bSetup == false{
|
||||||
|
log.Error("Template service not found",log.String("service name",serviceName),log.String("template service name",templateServiceName))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, s := range preSetupService {
|
for _, s := range preSetupService {
|
||||||
if s.GetName() != serviceName {
|
if s.GetName() != serviceName {
|
||||||
continue
|
continue
|
||||||
@@ -367,6 +393,12 @@ func Setup(s ...service.IService) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SetupTemplate(fs ...func()service.IService){
|
||||||
|
for _, f := range fs {
|
||||||
|
preSetupTemplateService = append(preSetupTemplateService, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func GetService(serviceName string) service.IService {
|
func GetService(serviceName string) service.IService {
|
||||||
return service.GetService(serviceName)
|
return service.GetService(serviceName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.31.0
|
// protoc-gen-go v1.31.0
|
||||||
// protoc v3.11.4
|
// protoc v4.24.0
|
||||||
// source: test/rpc/messagequeue.proto
|
// source: rpcproto/messagequeue.proto
|
||||||
|
|
||||||
package rpc
|
package rpc
|
||||||
|
|
||||||
@@ -50,11 +50,11 @@ func (x SubscribeType) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (SubscribeType) Descriptor() protoreflect.EnumDescriptor {
|
func (SubscribeType) Descriptor() protoreflect.EnumDescriptor {
|
||||||
return file_test_rpc_messagequeue_proto_enumTypes[0].Descriptor()
|
return file_rpcproto_messagequeue_proto_enumTypes[0].Descriptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (SubscribeType) Type() protoreflect.EnumType {
|
func (SubscribeType) Type() protoreflect.EnumType {
|
||||||
return &file_test_rpc_messagequeue_proto_enumTypes[0]
|
return &file_rpcproto_messagequeue_proto_enumTypes[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x SubscribeType) Number() protoreflect.EnumNumber {
|
func (x SubscribeType) Number() protoreflect.EnumNumber {
|
||||||
@@ -63,7 +63,7 @@ func (x SubscribeType) Number() protoreflect.EnumNumber {
|
|||||||
|
|
||||||
// Deprecated: Use SubscribeType.Descriptor instead.
|
// Deprecated: Use SubscribeType.Descriptor instead.
|
||||||
func (SubscribeType) EnumDescriptor() ([]byte, []int) {
|
func (SubscribeType) EnumDescriptor() ([]byte, []int) {
|
||||||
return file_test_rpc_messagequeue_proto_rawDescGZIP(), []int{0}
|
return file_rpcproto_messagequeue_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubscribeMethod int32
|
type SubscribeMethod int32
|
||||||
@@ -96,11 +96,11 @@ func (x SubscribeMethod) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (SubscribeMethod) Descriptor() protoreflect.EnumDescriptor {
|
func (SubscribeMethod) Descriptor() protoreflect.EnumDescriptor {
|
||||||
return file_test_rpc_messagequeue_proto_enumTypes[1].Descriptor()
|
return file_rpcproto_messagequeue_proto_enumTypes[1].Descriptor()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (SubscribeMethod) Type() protoreflect.EnumType {
|
func (SubscribeMethod) Type() protoreflect.EnumType {
|
||||||
return &file_test_rpc_messagequeue_proto_enumTypes[1]
|
return &file_rpcproto_messagequeue_proto_enumTypes[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x SubscribeMethod) Number() protoreflect.EnumNumber {
|
func (x SubscribeMethod) Number() protoreflect.EnumNumber {
|
||||||
@@ -109,7 +109,7 @@ func (x SubscribeMethod) Number() protoreflect.EnumNumber {
|
|||||||
|
|
||||||
// Deprecated: Use SubscribeMethod.Descriptor instead.
|
// Deprecated: Use SubscribeMethod.Descriptor instead.
|
||||||
func (SubscribeMethod) EnumDescriptor() ([]byte, []int) {
|
func (SubscribeMethod) EnumDescriptor() ([]byte, []int) {
|
||||||
return file_test_rpc_messagequeue_proto_rawDescGZIP(), []int{1}
|
return file_rpcproto_messagequeue_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DBQueuePopReq struct {
|
type DBQueuePopReq struct {
|
||||||
@@ -127,7 +127,7 @@ type DBQueuePopReq struct {
|
|||||||
func (x *DBQueuePopReq) Reset() {
|
func (x *DBQueuePopReq) Reset() {
|
||||||
*x = DBQueuePopReq{}
|
*x = DBQueuePopReq{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[0]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ func (x *DBQueuePopReq) String() string {
|
|||||||
func (*DBQueuePopReq) ProtoMessage() {}
|
func (*DBQueuePopReq) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *DBQueuePopReq) ProtoReflect() protoreflect.Message {
|
func (x *DBQueuePopReq) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[0]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -153,7 +153,7 @@ func (x *DBQueuePopReq) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use DBQueuePopReq.ProtoReflect.Descriptor instead.
|
// Deprecated: Use DBQueuePopReq.ProtoReflect.Descriptor instead.
|
||||||
func (*DBQueuePopReq) Descriptor() ([]byte, []int) {
|
func (*DBQueuePopReq) Descriptor() ([]byte, []int) {
|
||||||
return file_test_rpc_messagequeue_proto_rawDescGZIP(), []int{0}
|
return file_rpcproto_messagequeue_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBQueuePopReq) GetCustomerId() string {
|
func (x *DBQueuePopReq) GetCustomerId() string {
|
||||||
@@ -203,7 +203,7 @@ type DBQueuePopRes struct {
|
|||||||
func (x *DBQueuePopRes) Reset() {
|
func (x *DBQueuePopRes) Reset() {
|
||||||
*x = DBQueuePopRes{}
|
*x = DBQueuePopRes{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[1]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ func (x *DBQueuePopRes) String() string {
|
|||||||
func (*DBQueuePopRes) ProtoMessage() {}
|
func (*DBQueuePopRes) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *DBQueuePopRes) ProtoReflect() protoreflect.Message {
|
func (x *DBQueuePopRes) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[1]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[1]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -229,7 +229,7 @@ func (x *DBQueuePopRes) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use DBQueuePopRes.ProtoReflect.Descriptor instead.
|
// Deprecated: Use DBQueuePopRes.ProtoReflect.Descriptor instead.
|
||||||
func (*DBQueuePopRes) Descriptor() ([]byte, []int) {
|
func (*DBQueuePopRes) Descriptor() ([]byte, []int) {
|
||||||
return file_test_rpc_messagequeue_proto_rawDescGZIP(), []int{1}
|
return file_rpcproto_messagequeue_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBQueuePopRes) GetQueueName() string {
|
func (x *DBQueuePopRes) GetQueueName() string {
|
||||||
@@ -255,7 +255,7 @@ type DBQueueSubscribeReq struct {
|
|||||||
SubType SubscribeType `protobuf:"varint,1,opt,name=SubType,proto3,enum=SubscribeType" json:"SubType,omitempty"` //订阅类型
|
SubType SubscribeType `protobuf:"varint,1,opt,name=SubType,proto3,enum=SubscribeType" json:"SubType,omitempty"` //订阅类型
|
||||||
Method SubscribeMethod `protobuf:"varint,2,opt,name=Method,proto3,enum=SubscribeMethod" json:"Method,omitempty"` //订阅方法
|
Method SubscribeMethod `protobuf:"varint,2,opt,name=Method,proto3,enum=SubscribeMethod" json:"Method,omitempty"` //订阅方法
|
||||||
CustomerId string `protobuf:"bytes,3,opt,name=CustomerId,proto3" json:"CustomerId,omitempty"` //消费者Id
|
CustomerId string `protobuf:"bytes,3,opt,name=CustomerId,proto3" json:"CustomerId,omitempty"` //消费者Id
|
||||||
FromNodeId int32 `protobuf:"varint,4,opt,name=FromNodeId,proto3" json:"FromNodeId,omitempty"`
|
FromNodeId string `protobuf:"bytes,4,opt,name=FromNodeId,proto3" json:"FromNodeId,omitempty"`
|
||||||
RpcMethod string `protobuf:"bytes,5,opt,name=RpcMethod,proto3" json:"RpcMethod,omitempty"`
|
RpcMethod string `protobuf:"bytes,5,opt,name=RpcMethod,proto3" json:"RpcMethod,omitempty"`
|
||||||
TopicName string `protobuf:"bytes,6,opt,name=TopicName,proto3" json:"TopicName,omitempty"` //主题名称
|
TopicName string `protobuf:"bytes,6,opt,name=TopicName,proto3" json:"TopicName,omitempty"` //主题名称
|
||||||
StartIndex uint64 `protobuf:"varint,7,opt,name=StartIndex,proto3" json:"StartIndex,omitempty"` //开始位置 ,格式前4位是时间戳秒,后面是序号。如果填0时,服务自动修改成:(4bit 当前时间秒)| (0000 4bit)
|
StartIndex uint64 `protobuf:"varint,7,opt,name=StartIndex,proto3" json:"StartIndex,omitempty"` //开始位置 ,格式前4位是时间戳秒,后面是序号。如果填0时,服务自动修改成:(4bit 当前时间秒)| (0000 4bit)
|
||||||
@@ -265,7 +265,7 @@ type DBQueueSubscribeReq struct {
|
|||||||
func (x *DBQueueSubscribeReq) Reset() {
|
func (x *DBQueueSubscribeReq) Reset() {
|
||||||
*x = DBQueueSubscribeReq{}
|
*x = DBQueueSubscribeReq{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[2]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[2]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ func (x *DBQueueSubscribeReq) String() string {
|
|||||||
func (*DBQueueSubscribeReq) ProtoMessage() {}
|
func (*DBQueueSubscribeReq) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *DBQueueSubscribeReq) ProtoReflect() protoreflect.Message {
|
func (x *DBQueueSubscribeReq) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[2]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[2]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -291,7 +291,7 @@ func (x *DBQueueSubscribeReq) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use DBQueueSubscribeReq.ProtoReflect.Descriptor instead.
|
// Deprecated: Use DBQueueSubscribeReq.ProtoReflect.Descriptor instead.
|
||||||
func (*DBQueueSubscribeReq) Descriptor() ([]byte, []int) {
|
func (*DBQueueSubscribeReq) Descriptor() ([]byte, []int) {
|
||||||
return file_test_rpc_messagequeue_proto_rawDescGZIP(), []int{2}
|
return file_rpcproto_messagequeue_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBQueueSubscribeReq) GetSubType() SubscribeType {
|
func (x *DBQueueSubscribeReq) GetSubType() SubscribeType {
|
||||||
@@ -315,11 +315,11 @@ func (x *DBQueueSubscribeReq) GetCustomerId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBQueueSubscribeReq) GetFromNodeId() int32 {
|
func (x *DBQueueSubscribeReq) GetFromNodeId() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.FromNodeId
|
return x.FromNodeId
|
||||||
}
|
}
|
||||||
return 0
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBQueueSubscribeReq) GetRpcMethod() string {
|
func (x *DBQueueSubscribeReq) GetRpcMethod() string {
|
||||||
@@ -359,7 +359,7 @@ type DBQueueSubscribeRes struct {
|
|||||||
func (x *DBQueueSubscribeRes) Reset() {
|
func (x *DBQueueSubscribeRes) Reset() {
|
||||||
*x = DBQueueSubscribeRes{}
|
*x = DBQueueSubscribeRes{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[3]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -372,7 +372,7 @@ func (x *DBQueueSubscribeRes) String() string {
|
|||||||
func (*DBQueueSubscribeRes) ProtoMessage() {}
|
func (*DBQueueSubscribeRes) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *DBQueueSubscribeRes) ProtoReflect() protoreflect.Message {
|
func (x *DBQueueSubscribeRes) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[3]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -385,7 +385,7 @@ func (x *DBQueueSubscribeRes) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use DBQueueSubscribeRes.ProtoReflect.Descriptor instead.
|
// Deprecated: Use DBQueueSubscribeRes.ProtoReflect.Descriptor instead.
|
||||||
func (*DBQueueSubscribeRes) Descriptor() ([]byte, []int) {
|
func (*DBQueueSubscribeRes) Descriptor() ([]byte, []int) {
|
||||||
return file_test_rpc_messagequeue_proto_rawDescGZIP(), []int{3}
|
return file_rpcproto_messagequeue_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
type DBQueuePublishReq struct {
|
type DBQueuePublishReq struct {
|
||||||
@@ -400,7 +400,7 @@ type DBQueuePublishReq struct {
|
|||||||
func (x *DBQueuePublishReq) Reset() {
|
func (x *DBQueuePublishReq) Reset() {
|
||||||
*x = DBQueuePublishReq{}
|
*x = DBQueuePublishReq{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[4]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[4]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -413,7 +413,7 @@ func (x *DBQueuePublishReq) String() string {
|
|||||||
func (*DBQueuePublishReq) ProtoMessage() {}
|
func (*DBQueuePublishReq) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *DBQueuePublishReq) ProtoReflect() protoreflect.Message {
|
func (x *DBQueuePublishReq) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[4]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[4]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -426,7 +426,7 @@ func (x *DBQueuePublishReq) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use DBQueuePublishReq.ProtoReflect.Descriptor instead.
|
// Deprecated: Use DBQueuePublishReq.ProtoReflect.Descriptor instead.
|
||||||
func (*DBQueuePublishReq) Descriptor() ([]byte, []int) {
|
func (*DBQueuePublishReq) Descriptor() ([]byte, []int) {
|
||||||
return file_test_rpc_messagequeue_proto_rawDescGZIP(), []int{4}
|
return file_rpcproto_messagequeue_proto_rawDescGZIP(), []int{4}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DBQueuePublishReq) GetTopicName() string {
|
func (x *DBQueuePublishReq) GetTopicName() string {
|
||||||
@@ -452,7 +452,7 @@ type DBQueuePublishRes struct {
|
|||||||
func (x *DBQueuePublishRes) Reset() {
|
func (x *DBQueuePublishRes) Reset() {
|
||||||
*x = DBQueuePublishRes{}
|
*x = DBQueuePublishRes{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[5]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[5]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -465,7 +465,7 @@ func (x *DBQueuePublishRes) String() string {
|
|||||||
func (*DBQueuePublishRes) ProtoMessage() {}
|
func (*DBQueuePublishRes) ProtoMessage() {}
|
||||||
|
|
||||||
func (x *DBQueuePublishRes) ProtoReflect() protoreflect.Message {
|
func (x *DBQueuePublishRes) ProtoReflect() protoreflect.Message {
|
||||||
mi := &file_test_rpc_messagequeue_proto_msgTypes[5]
|
mi := &file_rpcproto_messagequeue_proto_msgTypes[5]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -478,13 +478,13 @@ func (x *DBQueuePublishRes) ProtoReflect() protoreflect.Message {
|
|||||||
|
|
||||||
// Deprecated: Use DBQueuePublishRes.ProtoReflect.Descriptor instead.
|
// Deprecated: Use DBQueuePublishRes.ProtoReflect.Descriptor instead.
|
||||||
func (*DBQueuePublishRes) Descriptor() ([]byte, []int) {
|
func (*DBQueuePublishRes) Descriptor() ([]byte, []int) {
|
||||||
return file_test_rpc_messagequeue_proto_rawDescGZIP(), []int{5}
|
return file_rpcproto_messagequeue_proto_rawDescGZIP(), []int{5}
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_test_rpc_messagequeue_proto protoreflect.FileDescriptor
|
var File_rpcproto_messagequeue_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_test_rpc_messagequeue_proto_rawDesc = []byte{
|
var file_rpcproto_messagequeue_proto_rawDesc = []byte{
|
||||||
0x0a, 0x1b, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61,
|
0x0a, 0x1b, 0x72, 0x70, 0x63, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61,
|
||||||
0x67, 0x65, 0x71, 0x75, 0x65, 0x75, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01,
|
0x67, 0x65, 0x71, 0x75, 0x65, 0x75, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x01,
|
||||||
0x0a, 0x0d, 0x44, 0x42, 0x51, 0x75, 0x65, 0x75, 0x65, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x12,
|
0x0a, 0x0d, 0x44, 0x42, 0x51, 0x75, 0x65, 0x75, 0x65, 0x50, 0x6f, 0x70, 0x52, 0x65, 0x71, 0x12,
|
||||||
0x1e, 0x0a, 0x0a, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20,
|
0x1e, 0x0a, 0x0a, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20,
|
||||||
@@ -510,7 +510,7 @@ var file_test_rpc_messagequeue_proto_rawDesc = []byte{
|
|||||||
0x6f, 0x64, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x75,
|
0x6f, 0x64, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x75,
|
||||||
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
|
0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
|
||||||
0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x46, 0x72,
|
0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x46, 0x72,
|
||||||
0x6f, 0x6d, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
|
0x6f, 0x6d, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a,
|
||||||
0x46, 0x72, 0x6f, 0x6d, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x52, 0x70,
|
0x46, 0x72, 0x6f, 0x6d, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x52, 0x70,
|
||||||
0x63, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x52,
|
0x63, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x52,
|
||||||
0x70, 0x63, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x6f, 0x70, 0x69,
|
0x70, 0x63, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x6f, 0x70, 0x69,
|
||||||
@@ -539,20 +539,20 @@ var file_test_rpc_messagequeue_proto_rawDesc = []byte{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_test_rpc_messagequeue_proto_rawDescOnce sync.Once
|
file_rpcproto_messagequeue_proto_rawDescOnce sync.Once
|
||||||
file_test_rpc_messagequeue_proto_rawDescData = file_test_rpc_messagequeue_proto_rawDesc
|
file_rpcproto_messagequeue_proto_rawDescData = file_rpcproto_messagequeue_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_test_rpc_messagequeue_proto_rawDescGZIP() []byte {
|
func file_rpcproto_messagequeue_proto_rawDescGZIP() []byte {
|
||||||
file_test_rpc_messagequeue_proto_rawDescOnce.Do(func() {
|
file_rpcproto_messagequeue_proto_rawDescOnce.Do(func() {
|
||||||
file_test_rpc_messagequeue_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_rpc_messagequeue_proto_rawDescData)
|
file_rpcproto_messagequeue_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpcproto_messagequeue_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_test_rpc_messagequeue_proto_rawDescData
|
return file_rpcproto_messagequeue_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_test_rpc_messagequeue_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
var file_rpcproto_messagequeue_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||||
var file_test_rpc_messagequeue_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
var file_rpcproto_messagequeue_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||||
var file_test_rpc_messagequeue_proto_goTypes = []interface{}{
|
var file_rpcproto_messagequeue_proto_goTypes = []interface{}{
|
||||||
(SubscribeType)(0), // 0: SubscribeType
|
(SubscribeType)(0), // 0: SubscribeType
|
||||||
(SubscribeMethod)(0), // 1: SubscribeMethod
|
(SubscribeMethod)(0), // 1: SubscribeMethod
|
||||||
(*DBQueuePopReq)(nil), // 2: DBQueuePopReq
|
(*DBQueuePopReq)(nil), // 2: DBQueuePopReq
|
||||||
@@ -562,7 +562,7 @@ var file_test_rpc_messagequeue_proto_goTypes = []interface{}{
|
|||||||
(*DBQueuePublishReq)(nil), // 6: DBQueuePublishReq
|
(*DBQueuePublishReq)(nil), // 6: DBQueuePublishReq
|
||||||
(*DBQueuePublishRes)(nil), // 7: DBQueuePublishRes
|
(*DBQueuePublishRes)(nil), // 7: DBQueuePublishRes
|
||||||
}
|
}
|
||||||
var file_test_rpc_messagequeue_proto_depIdxs = []int32{
|
var file_rpcproto_messagequeue_proto_depIdxs = []int32{
|
||||||
0, // 0: DBQueueSubscribeReq.SubType:type_name -> SubscribeType
|
0, // 0: DBQueueSubscribeReq.SubType:type_name -> SubscribeType
|
||||||
1, // 1: DBQueueSubscribeReq.Method:type_name -> SubscribeMethod
|
1, // 1: DBQueueSubscribeReq.Method:type_name -> SubscribeMethod
|
||||||
2, // [2:2] is the sub-list for method output_type
|
2, // [2:2] is the sub-list for method output_type
|
||||||
@@ -572,13 +572,13 @@ var file_test_rpc_messagequeue_proto_depIdxs = []int32{
|
|||||||
0, // [0:2] is the sub-list for field type_name
|
0, // [0:2] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_test_rpc_messagequeue_proto_init() }
|
func init() { file_rpcproto_messagequeue_proto_init() }
|
||||||
func file_test_rpc_messagequeue_proto_init() {
|
func file_rpcproto_messagequeue_proto_init() {
|
||||||
if File_test_rpc_messagequeue_proto != nil {
|
if File_rpcproto_messagequeue_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_test_rpc_messagequeue_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_messagequeue_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*DBQueuePopReq); i {
|
switch v := v.(*DBQueuePopReq); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -590,7 +590,7 @@ func file_test_rpc_messagequeue_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_test_rpc_messagequeue_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_messagequeue_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*DBQueuePopRes); i {
|
switch v := v.(*DBQueuePopRes); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -602,7 +602,7 @@ func file_test_rpc_messagequeue_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_test_rpc_messagequeue_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_messagequeue_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*DBQueueSubscribeReq); i {
|
switch v := v.(*DBQueueSubscribeReq); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -614,7 +614,7 @@ func file_test_rpc_messagequeue_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_test_rpc_messagequeue_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_messagequeue_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*DBQueueSubscribeRes); i {
|
switch v := v.(*DBQueueSubscribeRes); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -626,7 +626,7 @@ func file_test_rpc_messagequeue_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_test_rpc_messagequeue_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_messagequeue_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*DBQueuePublishReq); i {
|
switch v := v.(*DBQueuePublishReq); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -638,7 +638,7 @@ func file_test_rpc_messagequeue_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_test_rpc_messagequeue_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
file_rpcproto_messagequeue_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*DBQueuePublishRes); i {
|
switch v := v.(*DBQueuePublishRes); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -655,19 +655,19 @@ func file_test_rpc_messagequeue_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_test_rpc_messagequeue_proto_rawDesc,
|
RawDescriptor: file_rpcproto_messagequeue_proto_rawDesc,
|
||||||
NumEnums: 2,
|
NumEnums: 2,
|
||||||
NumMessages: 6,
|
NumMessages: 6,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
GoTypes: file_test_rpc_messagequeue_proto_goTypes,
|
GoTypes: file_rpcproto_messagequeue_proto_goTypes,
|
||||||
DependencyIndexes: file_test_rpc_messagequeue_proto_depIdxs,
|
DependencyIndexes: file_rpcproto_messagequeue_proto_depIdxs,
|
||||||
EnumInfos: file_test_rpc_messagequeue_proto_enumTypes,
|
EnumInfos: file_rpcproto_messagequeue_proto_enumTypes,
|
||||||
MessageInfos: file_test_rpc_messagequeue_proto_msgTypes,
|
MessageInfos: file_rpcproto_messagequeue_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_test_rpc_messagequeue_proto = out.File
|
File_rpcproto_messagequeue_proto = out.File
|
||||||
file_test_rpc_messagequeue_proto_rawDesc = nil
|
file_rpcproto_messagequeue_proto_rawDesc = nil
|
||||||
file_test_rpc_messagequeue_proto_goTypes = nil
|
file_rpcproto_messagequeue_proto_goTypes = nil
|
||||||
file_test_rpc_messagequeue_proto_depIdxs = nil
|
file_rpcproto_messagequeue_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ message DBQueueSubscribeReq {
|
|||||||
SubscribeType SubType = 1; //订阅类型
|
SubscribeType SubType = 1; //订阅类型
|
||||||
SubscribeMethod Method = 2; //订阅方法
|
SubscribeMethod Method = 2; //订阅方法
|
||||||
string CustomerId = 3; //消费者Id
|
string CustomerId = 3; //消费者Id
|
||||||
int32 FromNodeId = 4;
|
string FromNodeId = 4;
|
||||||
string RpcMethod = 5;
|
string RpcMethod = 5;
|
||||||
string TopicName = 6; //主题名称
|
string TopicName = 6; //主题名称
|
||||||
uint64 StartIndex = 7; //开始位置 ,格式前4位是时间戳秒,后面是序号。如果填0时,服务自动修改成:(4bit 当前时间秒)| (0000 4bit)
|
uint64 StartIndex = 7; //开始位置 ,格式前4位是时间戳秒,后面是序号。如果填0时,服务自动修改成:(4bit 当前时间秒)| (0000 4bit)
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxClusterNode int = 128
|
const maxClusterNode int = 32
|
||||||
|
|
||||||
type FuncRpcClient func(nodeId string, serviceMethod string,filterRetire bool, client []*Client) (error, int)
|
type FuncRpcClient func(nodeId string, serviceMethod string,filterRetire bool, client []*Client) (error, []*Client)
|
||||||
type FuncRpcServer func() IServer
|
type FuncRpcServer func() IServer
|
||||||
const NodeIdNull = ""
|
const NodeIdNull = ""
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ type RpcHandler struct {
|
|||||||
funcRpcClient FuncRpcClient
|
funcRpcClient FuncRpcClient
|
||||||
funcRpcServer FuncRpcServer
|
funcRpcServer FuncRpcServer
|
||||||
|
|
||||||
pClientList []*Client
|
//pClientList []*Client
|
||||||
}
|
}
|
||||||
|
|
||||||
//type TriggerRpcConnEvent func(bConnect bool, clientSeq uint32, nodeId string)
|
//type TriggerRpcConnEvent func(bConnect bool, clientSeq uint32, nodeId string)
|
||||||
@@ -135,7 +135,6 @@ func (handler *RpcHandler) InitRpcHandler(rpcHandler IRpcHandler, getClientFun F
|
|||||||
handler.mapFunctions = map[string]RpcMethodInfo{}
|
handler.mapFunctions = map[string]RpcMethodInfo{}
|
||||||
handler.funcRpcClient = getClientFun
|
handler.funcRpcClient = getClientFun
|
||||||
handler.funcRpcServer = getServerFun
|
handler.funcRpcServer = getServerFun
|
||||||
handler.pClientList = make([]*Client, maxClusterNode)
|
|
||||||
handler.RegisterRpc(rpcHandler)
|
handler.RegisterRpc(rpcHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +273,7 @@ func (handler *RpcHandler) HandlerRpcRequest(request *RpcRequest) {
|
|||||||
//普通的rpc请求
|
//普通的rpc请求
|
||||||
v, ok := handler.mapFunctions[request.RpcRequestData.GetServiceMethod()]
|
v, ok := handler.mapFunctions[request.RpcRequestData.GetServiceMethod()]
|
||||||
if ok == false {
|
if ok == false {
|
||||||
err := "RpcHandler " + handler.rpcHandler.GetName() + "cannot find " + request.RpcRequestData.GetServiceMethod()
|
err := "RpcHandler " + handler.rpcHandler.GetName() + " cannot find " + request.RpcRequestData.GetServiceMethod()
|
||||||
log.Error("HandlerRpcRequest cannot find serviceMethod",log.String("RpcHandlerName",handler.rpcHandler.GetName()),log.String("serviceMethod",request.RpcRequestData.GetServiceMethod()))
|
log.Error("HandlerRpcRequest cannot find serviceMethod",log.String("RpcHandlerName",handler.rpcHandler.GetName()),log.String("serviceMethod",request.RpcRequestData.GetServiceMethod()))
|
||||||
if request.requestHandle != nil {
|
if request.requestHandle != nil {
|
||||||
request.requestHandle(nil, RpcError(err))
|
request.requestHandle(nil, RpcError(err))
|
||||||
@@ -435,9 +434,9 @@ func (handler *RpcHandler) CallMethod(client *Client,ServiceMethod string, param
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (handler *RpcHandler) goRpc(processor IRpcProcessor, bCast bool, nodeId string, serviceMethod string, args interface{}) error {
|
func (handler *RpcHandler) goRpc(processor IRpcProcessor, bCast bool, nodeId string, serviceMethod string, args interface{}) error {
|
||||||
var pClientList [maxClusterNode]*Client
|
pClientList :=make([]*Client,0,maxClusterNode)
|
||||||
err, count := handler.funcRpcClient(nodeId, serviceMethod,false, pClientList[:])
|
err, pClientList := handler.funcRpcClient(nodeId, serviceMethod,false, pClientList)
|
||||||
if count == 0 {
|
if len(pClientList) == 0 {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("call serviceMethod is failed",log.String("serviceMethod",serviceMethod),log.ErrorAttr("error",err))
|
log.Error("call serviceMethod is failed",log.String("serviceMethod",serviceMethod),log.ErrorAttr("error",err))
|
||||||
} else {
|
} else {
|
||||||
@@ -446,13 +445,13 @@ func (handler *RpcHandler) goRpc(processor IRpcProcessor, bCast bool, nodeId str
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if count > 1 && bCast == false {
|
if len(pClientList) > 1 && bCast == false {
|
||||||
log.Error("cannot call serviceMethod more then 1 node",log.String("serviceMethod",serviceMethod))
|
log.Error("cannot call serviceMethod more then 1 node",log.String("serviceMethod",serviceMethod))
|
||||||
return errors.New("cannot call more then 1 node")
|
return errors.New("cannot call more then 1 node")
|
||||||
}
|
}
|
||||||
|
|
||||||
//2.rpcClient调用
|
//2.rpcClient调用
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < len(pClientList); i++ {
|
||||||
pCall := pClientList[i].Go(pClientList[i].GetTargetNodeId(),DefaultRpcTimeout,handler.rpcHandler,true, serviceMethod, args, nil)
|
pCall := pClientList[i].Go(pClientList[i].GetTargetNodeId(),DefaultRpcTimeout,handler.rpcHandler,true, serviceMethod, args, nil)
|
||||||
if pCall.Err != nil {
|
if pCall.Err != nil {
|
||||||
err = pCall.Err
|
err = pCall.Err
|
||||||
@@ -465,16 +464,16 @@ func (handler *RpcHandler) goRpc(processor IRpcProcessor, bCast bool, nodeId str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (handler *RpcHandler) callRpc(timeout time.Duration,nodeId string, serviceMethod string, args interface{}, reply interface{}) error {
|
func (handler *RpcHandler) callRpc(timeout time.Duration,nodeId string, serviceMethod string, args interface{}, reply interface{}) error {
|
||||||
var pClientList [maxClusterNode]*Client
|
pClientList :=make([]*Client,0,maxClusterNode)
|
||||||
err, count := handler.funcRpcClient(nodeId, serviceMethod,false, pClientList[:])
|
err, pClientList := handler.funcRpcClient(nodeId, serviceMethod,false, pClientList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Call serviceMethod is failed",log.ErrorAttr("error",err))
|
log.Error("Call serviceMethod is failed",log.ErrorAttr("error",err))
|
||||||
return err
|
return err
|
||||||
} else if count <= 0 {
|
} else if len(pClientList) <= 0 {
|
||||||
err = errors.New("Call serviceMethod is error:cannot find " + serviceMethod)
|
err = errors.New("Call serviceMethod is error:cannot find " + serviceMethod)
|
||||||
log.Error("cannot find serviceMethod",log.String("serviceMethod",serviceMethod))
|
log.Error("cannot find serviceMethod",log.String("serviceMethod",serviceMethod))
|
||||||
return err
|
return err
|
||||||
} else if count > 1 {
|
} else if len(pClientList) > 1 {
|
||||||
log.Error("Cannot call more then 1 node!",log.String("serviceMethod",serviceMethod))
|
log.Error("Cannot call more then 1 node!",log.String("serviceMethod",serviceMethod))
|
||||||
return errors.New("cannot call more then 1 node")
|
return errors.New("cannot call more then 1 node")
|
||||||
}
|
}
|
||||||
@@ -509,9 +508,9 @@ func (handler *RpcHandler) asyncCallRpc(timeout time.Duration,nodeId string, ser
|
|||||||
}
|
}
|
||||||
|
|
||||||
reply := reflect.New(fVal.Type().In(0).Elem()).Interface()
|
reply := reflect.New(fVal.Type().In(0).Elem()).Interface()
|
||||||
var pClientList [2]*Client
|
pClientList :=make([]*Client,0,1)
|
||||||
err, count := handler.funcRpcClient(nodeId, serviceMethod,false, pClientList[:])
|
err, pClientList := handler.funcRpcClient(nodeId, serviceMethod,false, pClientList[:])
|
||||||
if count == 0 || err != nil {
|
if len(pClientList) == 0 || err != nil {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if nodeId != NodeIdNull {
|
if nodeId != NodeIdNull {
|
||||||
err = fmt.Errorf("cannot find %s from nodeId %d",serviceMethod,nodeId)
|
err = fmt.Errorf("cannot find %s from nodeId %d",serviceMethod,nodeId)
|
||||||
@@ -524,7 +523,7 @@ func (handler *RpcHandler) asyncCallRpc(timeout time.Duration,nodeId string, ser
|
|||||||
return emptyCancelRpc,nil
|
return emptyCancelRpc,nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if count > 1 {
|
if len(pClientList) > 1 {
|
||||||
err := errors.New("cannot call more then 1 node")
|
err := errors.New("cannot call more then 1 node")
|
||||||
fVal.Call([]reflect.Value{reflect.ValueOf(reply), reflect.ValueOf(err)})
|
fVal.Call([]reflect.Value{reflect.ValueOf(reply), reflect.ValueOf(err)})
|
||||||
log.Error("cannot call more then 1 node",log.String("serviceMethod",serviceMethod))
|
log.Error("cannot call more then 1 node",log.String("serviceMethod",serviceMethod))
|
||||||
@@ -593,12 +592,13 @@ func (handler *RpcHandler) CastGo(serviceMethod string, args interface{}) error
|
|||||||
|
|
||||||
func (handler *RpcHandler) RawGoNode(rpcProcessorType RpcProcessorType, nodeId string, rpcMethodId uint32, serviceName string, rawArgs []byte) error {
|
func (handler *RpcHandler) RawGoNode(rpcProcessorType RpcProcessorType, nodeId string, rpcMethodId uint32, serviceName string, rawArgs []byte) error {
|
||||||
processor := GetProcessor(uint8(rpcProcessorType))
|
processor := GetProcessor(uint8(rpcProcessorType))
|
||||||
err, count := handler.funcRpcClient(nodeId, serviceName,false, handler.pClientList)
|
pClientList := make([]*Client,0,1)
|
||||||
if count == 0 || err != nil {
|
err, pClientList := handler.funcRpcClient(nodeId, serviceName,false, pClientList)
|
||||||
|
if len(pClientList) == 0 || err != nil {
|
||||||
log.Error("call serviceMethod is failed",log.ErrorAttr("error",err))
|
log.Error("call serviceMethod is failed",log.ErrorAttr("error",err))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if count > 1 {
|
if len(pClientList) > 1 {
|
||||||
err := errors.New("cannot call more then 1 node")
|
err := errors.New("cannot call more then 1 node")
|
||||||
log.Error("cannot call more then 1 node",log.String("serviceName",serviceName))
|
log.Error("cannot call more then 1 node",log.String("serviceName",serviceName))
|
||||||
return err
|
return err
|
||||||
@@ -606,14 +606,14 @@ func (handler *RpcHandler) RawGoNode(rpcProcessorType RpcProcessorType, nodeId s
|
|||||||
|
|
||||||
//2.rpcClient调用
|
//2.rpcClient调用
|
||||||
//如果调用本结点服务
|
//如果调用本结点服务
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < len(pClientList); i++ {
|
||||||
//跨node调用
|
//跨node调用
|
||||||
pCall := handler.pClientList[i].RawGo(handler.pClientList[i].GetTargetNodeId(),DefaultRpcTimeout,handler.rpcHandler,processor, true, rpcMethodId, serviceName, rawArgs, nil)
|
pCall := pClientList[i].RawGo(pClientList[i].GetTargetNodeId(),DefaultRpcTimeout,handler.rpcHandler,processor, true, rpcMethodId, serviceName, rawArgs, nil)
|
||||||
if pCall.Err != nil {
|
if pCall.Err != nil {
|
||||||
err = pCall.Err
|
err = pCall.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.pClientList[i].RemovePending(pCall.Seq)
|
pClientList[i].RemovePending(pCall.Seq)
|
||||||
ReleaseCall(pCall)
|
ReleaseCall(pCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import (
|
|||||||
var timerDispatcherLen = 100000
|
var timerDispatcherLen = 100000
|
||||||
var maxServiceEventChannelNum = 2000000
|
var maxServiceEventChannelNum = 2000000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
type IService interface {
|
type IService interface {
|
||||||
concurrent.IConcurrent
|
concurrent.IConcurrent
|
||||||
Init(iService IService,getClientFun rpc.FuncRpcClient,getServerFun rpc.FuncRpcServer,serviceCfg interface{})
|
Init(iService IService,getClientFun rpc.FuncRpcClient,getServerFun rpc.FuncRpcServer,serviceCfg interface{})
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package ginmodule
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"datacenter/common/processor"
|
|
||||||
"github.com/duanhf2012/origin/v2/event"
|
"github.com/duanhf2012/origin/v2/event"
|
||||||
"github.com/duanhf2012/origin/v2/log"
|
"github.com/duanhf2012/origin/v2/log"
|
||||||
"github.com/duanhf2012/origin/v2/service"
|
"github.com/duanhf2012/origin/v2/service"
|
||||||
@@ -10,34 +9,36 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type IGinProcessor interface {
|
||||||
|
Process(data *gin.Context) (*gin.Context, error)
|
||||||
|
}
|
||||||
|
|
||||||
type GinModule struct {
|
type GinModule struct {
|
||||||
service.Module
|
service.Module
|
||||||
|
|
||||||
*GinConf
|
|
||||||
*gin.Engine
|
*gin.Engine
|
||||||
srv *http.Server
|
srv *http.Server
|
||||||
|
|
||||||
processor []processor.IGinProcessor
|
listenAddr string
|
||||||
|
handleTimeout time.Duration
|
||||||
|
processor []IGinProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
type GinConf struct {
|
func (gm *GinModule) Init(addr string, handleTimeout time.Duration,engine *gin.Engine) {
|
||||||
Addr string
|
gm.listenAddr = addr
|
||||||
}
|
gm.handleTimeout = handleTimeout
|
||||||
|
|
||||||
const Sys_Event_Gin_Event event.EventType = -11
|
|
||||||
|
|
||||||
func (gm *GinModule) Init(conf *GinConf, engine *gin.Engine) {
|
|
||||||
gm.GinConf = conf
|
|
||||||
gm.Engine = engine
|
gm.Engine = engine
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) SetupDataProcessor(processor ...processor.IGinProcessor) {
|
func (gm *GinModule) SetupDataProcessor(processor ...IGinProcessor) {
|
||||||
gm.processor = processor
|
gm.processor = processor
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) AppendDataProcessor(processor ...processor.IGinProcessor) {
|
func (gm *GinModule) AppendDataProcessor(processor ...IGinProcessor) {
|
||||||
gm.processor = append(gm.processor, processor...)
|
gm.processor = append(gm.processor, processor...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,27 +48,28 @@ func (gm *GinModule) OnInit() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gm.srv = &http.Server{
|
gm.srv = &http.Server{
|
||||||
Addr: gm.Addr,
|
Addr: gm.listenAddr,
|
||||||
Handler: gm.Engine,
|
Handler: gm.Engine,
|
||||||
}
|
}
|
||||||
|
|
||||||
gm.Engine.Use(Logger())
|
gm.Engine.Use(Logger())
|
||||||
gm.Engine.Use(gin.Recovery())
|
gm.Engine.Use(gin.Recovery())
|
||||||
gm.GetEventProcessor().RegEventReceiverFunc(Sys_Event_Gin_Event, gm.GetEventHandler(), gm.eventHandler)
|
gm.GetEventProcessor().RegEventReceiverFunc(event.Sys_Event_Gin_Event, gm.GetEventHandler(), gm.eventHandler)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) eventHandler(ev event.IEvent) {
|
func (gm *GinModule) eventHandler(ev event.IEvent) {
|
||||||
ginEvent := ev.(*GinEvent)
|
ginEvent := ev.(*GinEvent)
|
||||||
for _, handler := range ginEvent.handlersChain {
|
for _, handler := range ginEvent.handlersChain {
|
||||||
handler(ginEvent.c)
|
handler(&ginEvent.c)
|
||||||
}
|
}
|
||||||
|
|
||||||
ginEvent.chanWait <- struct{}{}
|
//ginEvent.chanWait <- struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) Start() {
|
func (gm *GinModule) Start() {
|
||||||
log.Info("http start listen", slog.Any("addr", gm.Addr))
|
gm.srv.Addr = gm.listenAddr
|
||||||
|
log.Info("http start listen", slog.Any("addr", gm.listenAddr))
|
||||||
go func() {
|
go func() {
|
||||||
err := gm.srv.ListenAndServe()
|
err := gm.srv.ListenAndServe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -77,7 +79,7 @@ func (gm *GinModule) Start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) StartTLS(certFile, keyFile string) {
|
func (gm *GinModule) StartTLS(certFile, keyFile string) {
|
||||||
log.Info("http start listen", slog.Any("addr", gm.Addr))
|
log.Info("http start listen", slog.Any("addr", gm.listenAddr))
|
||||||
go func() {
|
go func() {
|
||||||
err := gm.srv.ListenAndServeTLS(certFile, keyFile)
|
err := gm.srv.ListenAndServeTLS(certFile, keyFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -92,17 +94,102 @@ func (gm *GinModule) Stop(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type GinEvent struct {
|
type SafeContext struct {
|
||||||
handlersChain gin.HandlersChain
|
*gin.Context
|
||||||
chanWait chan struct{}
|
chanWait chan struct{}
|
||||||
c *gin.Context
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) JSONAndDone(code int, obj any) {
|
||||||
|
c.Context.JSON(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) AsciiJSONAndDone(code int, obj any){
|
||||||
|
c.Context.AsciiJSON(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) PureJSONAndDone(code int, obj any){
|
||||||
|
c.Context.PureJSON(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) XMLAndDone(code int, obj any){
|
||||||
|
c.Context.XML(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) YAMLAndDone(code int, obj any){
|
||||||
|
c.Context.YAML(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) TOMLAndDone(code int, obj any){
|
||||||
|
c.Context.TOML(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) ProtoBufAndDone(code int, obj any){
|
||||||
|
c.Context.ProtoBuf(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) StringAndDone(code int, format string, values ...any){
|
||||||
|
c.Context.String(code,format,values...)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) RedirectAndDone(code int, location string){
|
||||||
|
c.Context.Redirect(code,location)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) DataAndDone(code int, contentType string, data []byte){
|
||||||
|
c.Context.Data(code,contentType,data)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) DataFromReaderAndDone(code int, contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string){
|
||||||
|
c.DataFromReader(code,contentLength,contentType,reader,extraHeaders)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) HTMLAndDone(code int, name string, obj any){
|
||||||
|
c.Context.HTML(code,name,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) IndentedJSONAndDone(code int, obj any){
|
||||||
|
c.Context.IndentedJSON(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) SecureJSONAndDone(code int, obj any){
|
||||||
|
c.Context.SecureJSON(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) JSONPAndDone(code int, obj any){
|
||||||
|
c.Context.JSONP(code,obj)
|
||||||
|
c.Done()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *SafeContext) Done(){
|
||||||
|
c.chanWait <- struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
type GinEvent struct {
|
||||||
|
handlersChain []SafeHandlerFunc
|
||||||
|
c SafeContext
|
||||||
|
}
|
||||||
|
|
||||||
|
type SafeHandlerFunc func(*SafeContext)
|
||||||
|
|
||||||
func (ge *GinEvent) GetEventType() event.EventType {
|
func (ge *GinEvent) GetEventType() event.EventType {
|
||||||
return Sys_Event_Gin_Event
|
return event.Sys_Event_Gin_Event
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) handleMethod(httpMethod, relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
func (gm *GinModule) handleMethod(httpMethod, relativePath string, handlers ...SafeHandlerFunc) gin.IRoutes {
|
||||||
return gm.Engine.Handle(httpMethod, relativePath, func(c *gin.Context) {
|
return gm.Engine.Handle(httpMethod, relativePath, func(c *gin.Context) {
|
||||||
for _, p := range gm.processor {
|
for _, p := range gm.processor {
|
||||||
_, err := p.Process(c)
|
_, err := p.Process(c)
|
||||||
@@ -112,33 +199,71 @@ func (gm *GinModule) handleMethod(httpMethod, relativePath string, handlers ...g
|
|||||||
}
|
}
|
||||||
|
|
||||||
var ev GinEvent
|
var ev GinEvent
|
||||||
chanWait := make(chan struct{})
|
chanWait := make(chan struct{},2)
|
||||||
ev.chanWait = chanWait
|
ev.c.chanWait = chanWait
|
||||||
ev.handlersChain = handlers
|
ev.handlersChain = handlers
|
||||||
ev.c = c
|
ev.c.Context = c
|
||||||
gm.NotifyEvent(&ev)
|
gm.NotifyEvent(&ev)
|
||||||
|
|
||||||
<-chanWait
|
ctx,cancel := context.WithTimeout(context.Background(), gm.handleTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
select{
|
||||||
|
case <-ctx.Done():
|
||||||
|
log.Error("GinModule process timeout", slog.Any("path", c.Request.URL.Path))
|
||||||
|
c.AbortWithStatus(http.StatusRequestTimeout)
|
||||||
|
case <-chanWait:
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) SafeGET(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
// GET 回调处理是在gin协程中
|
||||||
|
func (gm *GinModule) GET(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
|
return gm.Engine.GET(relativePath, handlers...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST 回调处理是在gin协程中
|
||||||
|
func (gm *GinModule) POST(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
|
return gm.Engine.POST(relativePath, handlers...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE 回调处理是在gin协程中
|
||||||
|
func (gm *GinModule) DELETE(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
|
return gm.Engine.DELETE(relativePath, handlers...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PATCH 回调处理是在gin协程中
|
||||||
|
func (gm *GinModule) PATCH(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
|
return gm.Engine.PATCH(relativePath, handlers...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put 回调处理是在gin协程中
|
||||||
|
func (gm *GinModule) Put(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
||||||
|
return gm.Engine.PUT(relativePath, handlers...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SafeGET 回调处理是在service协程中
|
||||||
|
func (gm *GinModule) SafeGET(relativePath string, handlers ...SafeHandlerFunc) gin.IRoutes {
|
||||||
return gm.handleMethod(http.MethodGet, relativePath, handlers...)
|
return gm.handleMethod(http.MethodGet, relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) SafePOST(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
// SafePOST 回调处理是在service协程中
|
||||||
|
func (gm *GinModule) SafePOST(relativePath string, handlers ...SafeHandlerFunc) gin.IRoutes {
|
||||||
return gm.handleMethod(http.MethodPost, relativePath, handlers...)
|
return gm.handleMethod(http.MethodPost, relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) SafeDELETE(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
// SafeDELETE 回调处理是在service协程中
|
||||||
|
func (gm *GinModule) SafeDELETE(relativePath string, handlers ...SafeHandlerFunc) gin.IRoutes {
|
||||||
return gm.handleMethod(http.MethodDelete, relativePath, handlers...)
|
return gm.handleMethod(http.MethodDelete, relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) SafePATCH(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
// SafePATCH 回调处理是在service协程中
|
||||||
|
func (gm *GinModule) SafePATCH(relativePath string, handlers ...SafeHandlerFunc) gin.IRoutes {
|
||||||
return gm.handleMethod(http.MethodPatch, relativePath, handlers...)
|
return gm.handleMethod(http.MethodPatch, relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gm *GinModule) SafePut(relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
// SafePut 回调处理是在service协程中
|
||||||
|
func (gm *GinModule) SafePut(relativePath string, handlers ...SafeHandlerFunc) gin.IRoutes {
|
||||||
return gm.handleMethod(http.MethodPut, relativePath, handlers...)
|
return gm.handleMethod(http.MethodPut, relativePath, handlers...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package ginmodule
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/duanhf2012/origin/log"
|
"github.com/duanhf2012/origin/v2/log"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type CustomerSubscriber struct {
|
|||||||
rpc.IRpcHandler
|
rpc.IRpcHandler
|
||||||
topic string
|
topic string
|
||||||
subscriber *Subscriber
|
subscriber *Subscriber
|
||||||
fromNodeId int
|
fromNodeId string
|
||||||
callBackRpcMethod string
|
callBackRpcMethod string
|
||||||
serviceName string
|
serviceName string
|
||||||
StartIndex uint64
|
StartIndex uint64
|
||||||
@@ -37,7 +37,7 @@ const (
|
|||||||
MethodLast SubscribeMethod = 1 //Last模式,以该消费者上次记录的位置开始订阅
|
MethodLast SubscribeMethod = 1 //Last模式,以该消费者上次记录的位置开始订阅
|
||||||
)
|
)
|
||||||
|
|
||||||
func (cs *CustomerSubscriber) trySetSubscriberBaseInfo(rpcHandler rpc.IRpcHandler, ss *Subscriber, topic string, subscribeMethod SubscribeMethod, customerId string, fromNodeId int, callBackRpcMethod string, startIndex uint64, oneBatchQuantity int32) error {
|
func (cs *CustomerSubscriber) trySetSubscriberBaseInfo(rpcHandler rpc.IRpcHandler, ss *Subscriber, topic string, subscribeMethod SubscribeMethod, customerId string, fromNodeId string, callBackRpcMethod string, startIndex uint64, oneBatchQuantity int32) error {
|
||||||
cs.subscriber = ss
|
cs.subscriber = ss
|
||||||
cs.fromNodeId = fromNodeId
|
cs.fromNodeId = fromNodeId
|
||||||
cs.callBackRpcMethod = callBackRpcMethod
|
cs.callBackRpcMethod = callBackRpcMethod
|
||||||
@@ -85,7 +85,7 @@ func (cs *CustomerSubscriber) trySetSubscriberBaseInfo(rpcHandler rpc.IRpcHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 开始订阅
|
// 开始订阅
|
||||||
func (cs *CustomerSubscriber) Subscribe(rpcHandler rpc.IRpcHandler, ss *Subscriber, topic string, subscribeMethod SubscribeMethod, customerId string, fromNodeId int, callBackRpcMethod string, startIndex uint64, oneBatchQuantity int32) error {
|
func (cs *CustomerSubscriber) Subscribe(rpcHandler rpc.IRpcHandler, ss *Subscriber, topic string, subscribeMethod SubscribeMethod, customerId string, fromNodeId string, callBackRpcMethod string, startIndex uint64, oneBatchQuantity int32) error {
|
||||||
err := cs.trySetSubscriberBaseInfo(rpcHandler, ss, topic, subscribeMethod, customerId, fromNodeId, callBackRpcMethod, startIndex, oneBatchQuantity)
|
err := cs.trySetSubscriberBaseInfo(rpcHandler, ss, topic, subscribeMethod, customerId, fromNodeId, callBackRpcMethod, startIndex, oneBatchQuantity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -122,5 +122,5 @@ func (ms *MessageQueueService) RPC_Publish(inParam *rpc.DBQueuePublishReq, outPa
|
|||||||
|
|
||||||
func (ms *MessageQueueService) RPC_Subscribe(req *rpc.DBQueueSubscribeReq, res *rpc.DBQueueSubscribeRes) error {
|
func (ms *MessageQueueService) RPC_Subscribe(req *rpc.DBQueueSubscribeReq, res *rpc.DBQueueSubscribeRes) error {
|
||||||
topicRoom := ms.GetTopicRoom(req.TopicName)
|
topicRoom := ms.GetTopicRoom(req.TopicName)
|
||||||
return topicRoom.TopicSubscribe(ms.GetRpcHandler(), req.SubType, int32(req.Method), int(req.FromNodeId), req.RpcMethod, req.TopicName, req.CustomerId, req.StartIndex, req.OneBatchQuantity)
|
return topicRoom.TopicSubscribe(ms.GetRpcHandler(), req.SubType, int32(req.Method), req.FromNodeId, req.RpcMethod, req.TopicName, req.CustomerId, req.StartIndex, req.OneBatchQuantity)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func (ss *Subscriber) PersistTopicData(topic string, topics []TopicData, retryCo
|
|||||||
return ss.dataPersist.PersistTopicData(topic, topics, retryCount)
|
return ss.dataPersist.PersistTopicData(topic, topics, retryCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *Subscriber) TopicSubscribe(rpcHandler rpc.IRpcHandler, subScribeType rpc.SubscribeType, subscribeMethod SubscribeMethod, fromNodeId int, callBackRpcMethod string, topic string, customerId string, StartIndex uint64, oneBatchQuantity int32) error {
|
func (ss *Subscriber) TopicSubscribe(rpcHandler rpc.IRpcHandler, subScribeType rpc.SubscribeType, subscribeMethod SubscribeMethod, fromNodeId string, callBackRpcMethod string, topic string, customerId string, StartIndex uint64, oneBatchQuantity int32) error {
|
||||||
//取消订阅时
|
//取消订阅时
|
||||||
if subScribeType == rpc.SubscribeType_Unsubscribe {
|
if subScribeType == rpc.SubscribeType_Unsubscribe {
|
||||||
ss.UnSubscribe(customerId)
|
ss.UnSubscribe(customerId)
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ func (mp *MongoPersist) JugeTimeoutSave() bool{
|
|||||||
|
|
||||||
func (mp *MongoPersist) persistCoroutine(){
|
func (mp *MongoPersist) persistCoroutine(){
|
||||||
defer mp.waitGroup.Done()
|
defer mp.waitGroup.Done()
|
||||||
for atomic.LoadInt32(&mp.stop)==0 || mp.hasPersistData(){
|
for atomic.LoadInt32(&mp.stop)==0 {
|
||||||
//间隔时间sleep
|
//间隔时间sleep
|
||||||
time.Sleep(time.Second*1)
|
time.Sleep(time.Second*1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user