提交 60a964ae 编写于 作者: U Ulric Qin

bugfix: for range goroutine

上级 a7cf8f9e
......@@ -41,9 +41,9 @@ type RuleEval struct {
ctx context.Context
}
func (re *RuleEval) start() {
logger.Debugf("[prome_pull_alert_start][RuleEval: %+v]", re)
go func(re *RuleEval) {
func (re RuleEval) start() {
go func(re RuleEval) {
logger.Debugf("[prome_pull_alert_start][RuleEval: %+v]", re)
if re.R.PullExpr.EvaluationInterval <= 0 {
re.R.PullExpr.EvaluationInterval = DEFAULT_PULL_ALERT_INTERVAL
}
......@@ -72,7 +72,7 @@ func (re *RuleEval) start() {
}(re)
}
func (r *RuleEval) stop() {
func (r RuleEval) stop() {
logger.Debugf("[prome_pull_alert_stop][RuleEval: %+v]", r)
close(r.quiteChan)
}
......@@ -103,17 +103,17 @@ func (rm *RuleManager) SyncRules(ctx context.Context, rules []models.AlertRule)
}
// 停止旧的
for hash, t := range rm.activeRules {
for hash := range rm.activeRules {
if _, loaded := thisAllRules[hash]; !loaded {
t.stop()
rm.activeRules[hash].stop()
delete(rm.activeRules, hash)
}
}
rm.targetMtx.Unlock()
// 开启新的
for _, t := range thisNewRules {
t.start()
for hash := range thisNewRules {
thisNewRules[hash].start()
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册