mirror of https://github.com/shunfei/cronsun
node: 提取 group 处理函数
parent
630a4dab43
commit
2632648d46
17
node/node.go
17
node/node.go
|
@ -251,6 +251,16 @@ func (n *Node) modGroup(g *models.Group) {
|
|||
|
||||
// 增加当前节点
|
||||
if !oGroup.Included(n.ID) && g.Included(n.ID) {
|
||||
n.groupAddNode(g)
|
||||
return
|
||||
}
|
||||
|
||||
// 移除当前节点
|
||||
n.groupRmNode(g, oGroup)
|
||||
return
|
||||
}
|
||||
|
||||
func (n *Node) groupAddNode(g *models.Group) {
|
||||
n.groups[g.ID] = g
|
||||
jls := n.link[g.ID]
|
||||
if len(jls) == 0 {
|
||||
|
@ -280,9 +290,9 @@ func (n *Node) modGroup(g *models.Group) {
|
|||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 移除当前节点
|
||||
func (n *Node) groupRmNode(g, og *models.Group) {
|
||||
jls := n.link[g.ID]
|
||||
if len(jls) == 0 {
|
||||
n.groups[g.ID] = g
|
||||
|
@ -298,7 +308,7 @@ func (n *Node) modGroup(g *models.Group) {
|
|||
continue
|
||||
}
|
||||
|
||||
n.groups[oGroup.ID] = oGroup
|
||||
n.groups[og.ID] = og
|
||||
prevCmds := job.Cmds(n.ID, n.groups)
|
||||
n.groups[g.ID] = g
|
||||
cmds := job.Cmds(n.ID, n.groups)
|
||||
|
@ -314,7 +324,6 @@ func (n *Node) modGroup(g *models.Group) {
|
|||
}
|
||||
|
||||
n.groups[g.ID] = g
|
||||
return
|
||||
}
|
||||
|
||||
func (n *Node) watchJobs() {
|
||||
|
|
Loading…
Reference in New Issue