Chore: Remove Dispatch and AddHandler (#42603)

* Remove Dispatch

* Remove context.TODO()

* Remove AddHandler and Dispatch
This commit is contained in:
idafurjes
2021-12-02 18:08:59 +01:00
committed by GitHub
parent e79fe8e84e
commit c80e7764d8
28 changed files with 83 additions and 129 deletions
+7 -7
View File
@@ -134,7 +134,7 @@ func CreateDashboardSnapshot(c *models.ReqContext) response.Response {
metrics.MApiDashboardSnapshotCreate.Inc()
}
if err := bus.Dispatch(&cmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
c.JsonApiErr(500, "Failed to create snapshot", err)
return nil
}
@@ -158,7 +158,7 @@ func GetDashboardSnapshot(c *models.ReqContext) response.Response {
query := &models.GetDashboardSnapshotQuery{Key: key}
err := bus.Dispatch(query)
err := bus.DispatchCtx(c.Req.Context(), query)
if err != nil {
return response.Error(500, "Failed to get dashboard snapshot", err)
}
@@ -226,7 +226,7 @@ func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response
query := &models.GetDashboardSnapshotQuery{DeleteKey: key}
err := bus.Dispatch(query)
err := bus.DispatchCtx(c.Req.Context(), query)
if err != nil {
return response.Error(500, "Failed to get dashboard snapshot", err)
}
@@ -240,7 +240,7 @@ func DeleteDashboardSnapshotByDeleteKey(c *models.ReqContext) response.Response
cmd := &models.DeleteDashboardSnapshotCommand{DeleteKey: query.Result.DeleteKey}
if err := bus.Dispatch(cmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), cmd); err != nil {
return response.Error(500, "Failed to delete dashboard snapshot", err)
}
@@ -259,7 +259,7 @@ func DeleteDashboardSnapshot(c *models.ReqContext) response.Response {
query := &models.GetDashboardSnapshotQuery{Key: key}
err := bus.Dispatch(query)
err := bus.DispatchCtx(c.Req.Context(), query)
if err != nil {
return response.Error(500, "Failed to get dashboard snapshot", err)
}
@@ -288,7 +288,7 @@ func DeleteDashboardSnapshot(c *models.ReqContext) response.Response {
cmd := &models.DeleteDashboardSnapshotCommand{DeleteKey: query.Result.DeleteKey}
if err := bus.Dispatch(cmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), cmd); err != nil {
return response.Error(500, "Failed to delete dashboard snapshot", err)
}
@@ -314,7 +314,7 @@ func SearchDashboardSnapshots(c *models.ReqContext) response.Response {
SignedInUser: c.SignedInUser,
}
err := bus.Dispatch(&searchQuery)
err := bus.DispatchCtx(c.Req.Context(), &searchQuery)
if err != nil {
return response.Error(500, "Search failed", err)
}