Chore: Propagate context for data source provisioning (#40235)

* context all the things

* apply feedback

* rollback some alerting changes

* rollback some alerting changes #2

* more rollbacks

* more rollbacks #2

* more rollbacks #3

* more rollbacks #4

* fix integration test

* add missing context

* add missing and remove incorrect dispatch
This commit is contained in:
Will Browne
2021-10-18 17:06:19 +02:00
committed by GitHub
parent ec0fcbbf4b
commit e4297006f6
22 changed files with 129 additions and 112 deletions
+1 -1
View File
@@ -178,7 +178,7 @@ func (s *Service) queryData(ctx context.Context, req *backend.QueryDataRequest)
Uid: datasourceUID,
}
if err := bus.Dispatch(getDsInfo); err != nil {
if err := bus.DispatchCtx(ctx, getDsInfo); err != nil {
return nil, fmt.Errorf("could not find datasource: %w", err)
}
+2 -1
View File
@@ -1,6 +1,7 @@
package translate
import (
"context"
"encoding/json"
"fmt"
"sort"
@@ -188,7 +189,7 @@ func (dc *dashConditionsJSON) GetNew(orgID int64) (*ngmodels.Condition, error) {
Id: dc.Conditions[condIdx].Query.DatasourceID,
}
if err := bus.Dispatch(getDsInfo); err != nil {
if err := bus.DispatchCtx(context.TODO(), getDsInfo); err != nil {
return nil, fmt.Errorf("could not find datasource: %w", err)
}
+2 -1
View File
@@ -1,6 +1,7 @@
package translate
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
@@ -132,7 +133,7 @@ func alertRuleByRefId(cond *ngmodels.Condition, refID string) (ngmodels.AlertQue
}
func registerGetDsInfoHandler() {
bus.AddHandler("test", func(query *models.GetDataSourceQuery) error {
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.GetDataSourceQuery) error {
switch {
case query.Id == 2:
query.Result = &models.DataSource{Id: 2, OrgId: 1, Uid: "000000002"}