Compare commits

...

2 Commits

Author SHA1 Message Date
orgin
89fd5d273b 优化自恢复开协程函数GoRecover 2022-07-15 20:25:51 +08:00
orgin
3ce873ef04 优化获取NodeId接口 2022-07-11 15:34:28 +08:00
2 changed files with 6 additions and 4 deletions

View File

@@ -465,7 +465,7 @@ func GetNodeByServiceName(serviceName string) map[int]struct{} {
return nil return nil
} }
var mapNodeId map[int]struct{} mapNodeId := map[int]struct{}{}
for nodeId,_ := range mapNode { for nodeId,_ := range mapNode {
mapNodeId[nodeId] = struct{}{} mapNodeId[nodeId] = struct{}{}
} }

View File

@@ -2,6 +2,7 @@ package coroutine
import ( import (
"fmt" "fmt"
"github.com/duanhf2012/origin/log"
"reflect" "reflect"
"runtime/debug" "runtime/debug"
) )
@@ -12,10 +13,11 @@ func F(callback interface{},recoverNum int, args ...interface{}) {
var coreInfo string var coreInfo string
coreInfo = string(debug.Stack()) coreInfo = string(debug.Stack())
coreInfo += "\n" + fmt.Sprintf("Core information is %v\n", r) coreInfo += "\n" + fmt.Sprintf("Core information is %v\n", r)
fmt.Print(coreInfo) log.SError(coreInfo)
if recoverNum > 0{
if recoverNum==-1 ||recoverNum-1 >= 0 {
recoverNum -= 1 recoverNum -= 1
}
if recoverNum == -1 || recoverNum > 0 {
go F(callback,recoverNum, args...) go F(callback,recoverNum, args...)
} }
} }