优化节点到API节点连接管理

This commit is contained in:
GoEdgeLab
2021-08-08 16:17:25 +08:00
parent e979414973
commit a5118536e7
3 changed files with 19 additions and 5 deletions

View File

@@ -72,6 +72,7 @@ func (this *NodeTaskDAO) CreateNodeTask(tx *dbs.Tx, role string, clusterId int64
"isDone": 0, "isDone": 0,
"isOk": 0, "isOk": 0,
"error": "", "error": "",
"isNotified": 0,
}) })
return err return err
} }
@@ -291,6 +292,7 @@ func (this *NodeTaskDAO) FindAllDoingNodeIds(tx *dbs.Tx, role string) ([]int64,
Attr("role", role). Attr("role", role).
Gt("nodeId", 0). Gt("nodeId", 0).
Attr("isDone", false). Attr("isDone", false).
Attr("isNotified", 0).
FindAll() FindAll()
if err != nil { if err != nil {
return nil, err return nil, err

View File

@@ -170,6 +170,12 @@ func (this *NSNodeService) NsNodeStream(server pb.NSNodeService_NsNodeStreamServ
} }
nodeLocker.Unlock() nodeLocker.Unlock()
defer func() {
nodeLocker.Lock()
delete(requestChanMap, nodeId)
nodeLocker.Unlock()
}()
// 发送请求 // 发送请求
go func() { go func() {
for { for {

View File

@@ -134,6 +134,12 @@ func (this *NodeService) NodeStream(server pb.NodeService_NodeStreamServer) erro
} }
nodeLocker.Unlock() nodeLocker.Unlock()
defer func() {
nodeLocker.Lock()
delete(requestChanMap, nodeId)
nodeLocker.Unlock()
}()
// 发送请求 // 发送请求
go func() { go func() {
for { for {