mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2026-01-03 21:29:13 +08:00
消息中增加恢复成功的消息
This commit is contained in:
@@ -19,13 +19,17 @@ const (
|
||||
MessageLevelInfo = "info"
|
||||
MessageLevelWarning = "warning"
|
||||
MessageLevelError = "error"
|
||||
MessageLevelSuccess = "success"
|
||||
)
|
||||
|
||||
type MessageType = string
|
||||
|
||||
const (
|
||||
MessageTypeHealthCheckFailed MessageType = "HealthCheckFailed"
|
||||
MessageTypeHealthCheckNodeUp MessageType = "HealthCheckNodeUp"
|
||||
MessageTypeHealthCheckNodeDown MessageType = "HealthCheckNodeDown"
|
||||
MessageTypeNodeInactive MessageType = "NodeInactive"
|
||||
MessageTypeNodeActive MessageType = "NodeActive"
|
||||
MessageTypeClusterDNSSyncFailed MessageType = "ClusterDNSSyncFailed"
|
||||
)
|
||||
|
||||
|
||||
@@ -315,7 +315,9 @@ func (this *NodeDAO) FindAllInactiveNodesWithClusterId(clusterId int64) (result
|
||||
Attr("clusterId", clusterId).
|
||||
Attr("isOn", true). // 只监控启用的节点
|
||||
Attr("isInstalled", true). // 只监控已经安装的节点
|
||||
Attr("isActive", true). // 当前已经在线的
|
||||
Where("(status IS NULL OR (JSON_EXTRACT(status, '$.isActive')=false AND UNIX_TIMESTAMP()-JSON_EXTRACT(status, '$.updatedAt')>10) OR UNIX_TIMESTAMP()-JSON_EXTRACT(status, '$.updatedAt')>120)").
|
||||
Result("id").
|
||||
Slice(&result).
|
||||
FindAll()
|
||||
return
|
||||
@@ -664,7 +666,7 @@ func (this *NodeDAO) UpdateNodeUp(nodeId int64, isUp bool, maxUp int, maxDown in
|
||||
|
||||
// 如果新老状态一致,则不做任何事情
|
||||
if oldIsUp == isUp {
|
||||
return isUp, nil
|
||||
return false, nil
|
||||
}
|
||||
|
||||
countUp := int(one.(*Node).CountUp)
|
||||
@@ -700,6 +702,30 @@ func (this *NodeDAO) UpdateNodeUp(nodeId int64, isUp bool, maxUp int, maxDown in
|
||||
return
|
||||
}
|
||||
|
||||
// 修改节点活跃状态
|
||||
func (this *NodeDAO) UpdateNodeActive(nodeId int64, isActive bool) error {
|
||||
if nodeId <= 0 {
|
||||
return errors.New("invalid nodeId")
|
||||
}
|
||||
_, err := this.Query().
|
||||
Pk(nodeId).
|
||||
Set("isActive", isActive).
|
||||
Update()
|
||||
return err
|
||||
}
|
||||
|
||||
// 检查节点活跃状态
|
||||
func (this *NodeDAO) FindNodeActive(nodeId int64) (bool, error) {
|
||||
isActive, err := this.Query().
|
||||
Pk(nodeId).
|
||||
Result("isActive").
|
||||
FindIntCol(0)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return isActive == 1, nil
|
||||
}
|
||||
|
||||
// 生成唯一ID
|
||||
func (this *NodeDAO) genUniqueId() (string, error) {
|
||||
for {
|
||||
|
||||
@@ -9,6 +9,7 @@ type Node struct {
|
||||
IsUp uint8 `field:"isUp"` // 是否在线
|
||||
CountUp uint32 `field:"countUp"` // 连续在线次数
|
||||
CountDown uint32 `field:"countDown"` // 连续下线次数
|
||||
IsActive uint8 `field:"isActive"` // 是否活跃
|
||||
UniqueId string `field:"uniqueId"` // 节点ID
|
||||
Secret string `field:"secret"` // 密钥
|
||||
Name string `field:"name"` // 节点名
|
||||
@@ -37,6 +38,7 @@ type NodeOperator struct {
|
||||
IsUp interface{} // 是否在线
|
||||
CountUp interface{} // 连续在线次数
|
||||
CountDown interface{} // 连续下线次数
|
||||
IsActive interface{} // 是否活跃
|
||||
UniqueId interface{} // 节点ID
|
||||
Secret interface{} // 密钥
|
||||
Name interface{} // 节点名
|
||||
|
||||
Reference in New Issue
Block a user