Browse Source

code refactor: exec pull_prom early

tags/v5.8.0
Ulric Qin 5 years ago
parent
commit
1eecb324d0
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      judge/prome_pull.go

+ 6
- 2
judge/prome_pull.go View File

@@ -47,13 +47,16 @@ func (re RuleEval) start() {
if re.R.PullExpr.EvaluationInterval <= 0 { if re.R.PullExpr.EvaluationInterval <= 0 {
re.R.PullExpr.EvaluationInterval = DEFAULT_PULL_ALERT_INTERVAL re.R.PullExpr.EvaluationInterval = DEFAULT_PULL_ALERT_INTERVAL
} }

sleepDuration := time.Duration(re.R.PullExpr.EvaluationInterval) * time.Second

for { for {
select { select {
case <-re.ctx.Done(): case <-re.ctx.Done():
return return
case <-re.quiteChan: case <-re.quiteChan:
return return
case <-time.After(time.Duration(re.R.PullExpr.EvaluationInterval) * time.Second):
default:
} }


// 获取backend的prometheus DataSource // 获取backend的prometheus DataSource
@@ -67,8 +70,9 @@ func (re RuleEval) start() {
promVector := pb.QueryVector(re.R.PullExpr.PromQl) promVector := pb.QueryVector(re.R.PullExpr.PromQl)


handlePromqlVector(promVector, re.R) handlePromqlVector(promVector, re.R)
}


time.Sleep(sleepDuration)
}
}(re) }(re)
} }




Loading…
Cancel
Save