优化节点到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

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

View File

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

View File

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