Alerting: Schedule a shim implementation for recording rules (#87939)

* Add shim rule implementation for recording rules

* Give ruleFactory access to the original rule definition

* Schedule shim implementation if the rule is a recording rule

* Fix or suppress linter

* Fix nolint
This commit is contained in:
Alexander Weaver
2024-05-21 16:42:58 -05:00
committed by GitHub
parent fc11350554
commit 89b54d06e9
6 changed files with 76 additions and 17 deletions

View File

@@ -36,10 +36,10 @@ type Rule interface {
Update(lastVersion RuleVersionAndPauseStatus) bool
}
type ruleFactoryFunc func(context.Context) Rule
type ruleFactoryFunc func(context.Context, *ngmodels.AlertRule) Rule
func (f ruleFactoryFunc) new(ctx context.Context) Rule {
return f(ctx)
func (f ruleFactoryFunc) new(ctx context.Context, rule *ngmodels.AlertRule) Rule {
return f(ctx, rule)
}
func newRuleFactory(
@@ -57,7 +57,10 @@ func newRuleFactory(
evalAppliedHook evalAppliedFunc,
stopAppliedHook stopAppliedFunc,
) ruleFactoryFunc {
return func(ctx context.Context) Rule {
return func(ctx context.Context, rule *ngmodels.AlertRule) Rule {
if rule.IsRecordingRule() {
return newRecordingRule(ctx, logger)
}
return newAlertRule(
ctx,
appURL,