只有发送过离线通知的节点才会发送恢复在线通知

This commit is contained in:
GoEdgeLab
2022-08-07 17:28:54 +08:00
parent 2aa93e826d
commit d00061d3c4
4 changed files with 66 additions and 20 deletions

View File

@@ -1668,10 +1668,31 @@ func (this *NodeDAO) UpdateNodeActive(tx *dbs.Tx, nodeId int64, isActive bool) e
_, err := this.Query(tx).
Pk(nodeId).
Set("isActive", isActive).
Set("inactiveNotifiedAt", 0).
Update()
return err
}
// UpdateNodeInactiveNotifiedAt 修改节点的离线通知时间
func (this *NodeDAO) UpdateNodeInactiveNotifiedAt(tx *dbs.Tx, nodeId int64, inactiveAt int64) error {
if nodeId <= 0 {
return errors.New("invalid nodeId")
}
_, err := this.Query(tx).
Pk(nodeId).
Set("inactiveNotifiedAt", inactiveAt).
Update()
return err
}
// FindNodeInactiveNotifiedAt 读取上次的节点离线通知时间
func (this *NodeDAO) FindNodeInactiveNotifiedAt(tx *dbs.Tx, nodeId int64) (int64, error) {
return this.Query(tx).
Pk(nodeId).
Result("inactiveNotifiedAt").
FindInt64Col(0)
}
// FindNodeActive 检查节点活跃状态
func (this *NodeDAO) FindNodeActive(tx *dbs.Tx, nodeId int64) (bool, error) {
isActive, err := this.Query(tx).
@@ -1827,6 +1848,19 @@ func (this *NodeDAO) FindParentNodeConfigs(tx *dbs.Tx, nodeId int64, groupId int
if err != nil {
return nil, err
}
} else if nodeId > 0 {
// 当前节点所属分组
groupId, err = this.Query(tx).Result("groupId").FindInt64Col(0)
if err != nil {
return nil, err
}
if groupId > 0 {
parentNodes, err = this.FindEnabledNodesWithGroupIdAndLevel(tx, groupId, level+1)
if err != nil {
return nil, err
}
}
}
// 当前集群的L2

View File

@@ -13,6 +13,7 @@ type Node struct {
CountUp uint32 `field:"countUp"` // 连续在线次数
CountDown uint32 `field:"countDown"` // 连续下线次数
IsActive bool `field:"isActive"` // 是否活跃
InactiveNotifiedAt uint64 `field:"inactiveNotifiedAt"` // 离线通知时间
UniqueId string `field:"uniqueId"` // 节点ID
Secret string `field:"secret"` // 密钥
Name string `field:"name"` // 节点名
@@ -50,6 +51,7 @@ type NodeOperator struct {
CountUp interface{} // 连续在线次数
CountDown interface{} // 连续下线次数
IsActive interface{} // 是否活跃
InactiveNotifiedAt interface{} // 离线通知时间
UniqueId interface{} // 节点ID
Secret interface{} // 密钥
Name interface{} // 节点名