mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Restart rule routines if the type changes (#90867)
* Restart when types change * Wire up test hooks correctly * testing
This commit is contained in:
@@ -38,6 +38,8 @@ type Rule interface {
|
||||
Eval(eval *Evaluation) (bool, *Evaluation)
|
||||
// Update sends a singal to change the definition of the rule.
|
||||
Update(lastVersion RuleVersionAndPauseStatus) bool
|
||||
// Type gives the type of the rule.
|
||||
Type() ngmodels.RuleType
|
||||
}
|
||||
|
||||
type ruleFactoryFunc func(context.Context, *ngmodels.AlertRule) Rule
|
||||
@@ -76,6 +78,8 @@ func newRuleFactory(
|
||||
met,
|
||||
tracer,
|
||||
recordingWriter,
|
||||
evalAppliedHook,
|
||||
stopAppliedHook,
|
||||
)
|
||||
}
|
||||
return newAlertRule(
|
||||
@@ -172,6 +176,10 @@ func newAlertRule(
|
||||
}
|
||||
}
|
||||
|
||||
func (a *alertRule) Type() ngmodels.RuleType {
|
||||
return ngmodels.RuleTypeAlerting
|
||||
}
|
||||
|
||||
// eval signals the rule evaluation routine to perform the evaluation of the rule. Does nothing if the loop is stopped.
|
||||
// Before sending a message into the channel, it does non-blocking read to make sure that there is no concurrent send operation.
|
||||
// Returns a tuple where first element is
|
||||
|
||||
Reference in New Issue
Block a user