Make alerting notifcations sync (#6158)

* tech(routines): move the async logic from notification to alerting notifier

* tech(notification): reduce code dupe

* fix(notification): dont touch the response unless its an error

* feat(alerting): make alerting exeuction async but flow sync

* tech(alerting): remove commented code

* tech(alerting): remove unused code

* tech(alerting): fix typo

* tech(alerting): implement Context on EvalContext

* tech(alerting): wait for all alerts to return

* feat(alerting): dont allow alert responses to cancel

* Revert "feat(alerting): dont allow alert responses to cancel"

This reverts commit 324b006c96.

* feat(alerting): give alerts some time to finish before closing down
This commit is contained in:
Carl Bergquist
2016-10-03 09:38:03 +02:00
committed by Torkel Ödegaard
parent 36f0bf0e1e
commit c38f6ff182
30 changed files with 367 additions and 284 deletions
+8 -5
View File
@@ -1,6 +1,9 @@
package tsdb
import "errors"
import (
"context"
"errors"
)
type Batch struct {
DataSourceId int64
@@ -20,7 +23,7 @@ func newBatch(dsId int64, queries QuerySlice) *Batch {
}
}
func (bg *Batch) process(context *QueryContext) {
func (bg *Batch) process(ctx context.Context, queryContext *QueryContext) {
executor := getExecutorFor(bg.Queries[0].DataSource)
if executor == nil {
@@ -32,13 +35,13 @@ func (bg *Batch) process(context *QueryContext) {
for _, query := range bg.Queries {
result.QueryResults[query.RefId] = &QueryResult{Error: result.Error}
}
context.ResultsChan <- result
queryContext.ResultsChan <- result
return
}
res := executor.Execute(bg.Queries, context)
res := executor.Execute(ctx, bg.Queries, queryContext)
bg.Done = true
context.ResultsChan <- res
queryContext.ResultsChan <- res
}
func (bg *Batch) addQuery(query *Query) {