Skip to content

Commit 6edae37

Browse files
committed
feat(alerting): rename state response method
1 parent 403fdeb commit 6edae37

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

pkg/services/alerting/engine.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,19 @@ func (e *Engine) resultHandler() {
121121

122122
result.State = alertstates.Critical
123123
result.Description = fmt.Sprintf("Failed to run check after %d retires, Error: %v", maxAlertExecutionRetries, result.Error)
124-
e.saveState(result)
124+
e.reactToState(result)
125125
}
126126
} else {
127127
result.AlertJob.ResetRetry()
128-
e.saveState(result)
128+
e.reactToState(result)
129129
}
130130
}
131131
}
132132

133-
func (e *Engine) saveState(result *AlertResult) {
133+
func (e *Engine) reactToState(result *AlertResult) {
134134
query := &m.GetAlertByIdQuery{Id: result.AlertJob.Rule.Id}
135135
bus.Dispatch(query)
136136

137-
e.notifier.Notify(result)
138137
if query.Result.ShouldUpdateState(result.State) {
139138
cmd := &m.UpdateAlertStateCommand{
140139
AlertId: result.AlertJob.Rule.Id,
@@ -146,9 +145,7 @@ func (e *Engine) saveState(result *AlertResult) {
146145
e.log.Error("Failed to save state", "error", err)
147146
}
148147

149-
e.log.Debug("will notify! about", "new state", result.State)
150-
151-
} else {
152-
e.log.Debug("state remains the same!")
148+
e.log.Debug("will notify about new state", "new state", result.State)
149+
e.notifier.Notify(result)
153150
}
154151
}

0 commit comments

Comments
 (0)