Commit 6edae37a by bergquist

feat(alerting): rename state response method

parent 403fdebc
...@@ -121,20 +121,19 @@ func (e *Engine) resultHandler() { ...@@ -121,20 +121,19 @@ func (e *Engine) resultHandler() {
result.State = alertstates.Critical result.State = alertstates.Critical
result.Description = fmt.Sprintf("Failed to run check after %d retires, Error: %v", maxAlertExecutionRetries, result.Error) result.Description = fmt.Sprintf("Failed to run check after %d retires, Error: %v", maxAlertExecutionRetries, result.Error)
e.saveState(result) e.reactToState(result)
} }
} else { } else {
result.AlertJob.ResetRetry() result.AlertJob.ResetRetry()
e.saveState(result) e.reactToState(result)
} }
} }
} }
func (e *Engine) saveState(result *AlertResult) { func (e *Engine) reactToState(result *AlertResult) {
query := &m.GetAlertByIdQuery{Id: result.AlertJob.Rule.Id} query := &m.GetAlertByIdQuery{Id: result.AlertJob.Rule.Id}
bus.Dispatch(query) bus.Dispatch(query)
e.notifier.Notify(result)
if query.Result.ShouldUpdateState(result.State) { if query.Result.ShouldUpdateState(result.State) {
cmd := &m.UpdateAlertStateCommand{ cmd := &m.UpdateAlertStateCommand{
AlertId: result.AlertJob.Rule.Id, AlertId: result.AlertJob.Rule.Id,
...@@ -146,9 +145,7 @@ func (e *Engine) saveState(result *AlertResult) { ...@@ -146,9 +145,7 @@ func (e *Engine) saveState(result *AlertResult) {
e.log.Error("Failed to save state", "error", err) e.log.Error("Failed to save state", "error", err)
} }
e.log.Debug("will notify! about", "new state", result.State) e.log.Debug("will notify about new state", "new state", result.State)
e.notifier.Notify(result)
} else {
e.log.Debug("state remains the same!")
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment