Rename DispatchCtx to Dispatch (#43563)
This commit is contained in:
+13
-13
@@ -26,7 +26,7 @@ var datasourcesLogger = log.New("datasources")
|
||||
func (hs *HTTPServer) GetDataSources(c *models.ReqContext) response.Response {
|
||||
query := models.GetDataSourcesQuery{OrgId: c.OrgId, DataSourceLimit: hs.Cfg.DataSourceLimit}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
return response.Error(500, "Failed to query datasources", err)
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ func (hs *HTTPServer) GetDataSourceById(c *models.ReqContext) response.Response
|
||||
OrgId: c.OrgId,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
@@ -136,7 +136,7 @@ func (hs *HTTPServer) DeleteDataSourceById(c *models.ReqContext) response.Respon
|
||||
|
||||
cmd := &models.DeleteDataSourceCommand{ID: id, OrgID: c.OrgId}
|
||||
|
||||
err = bus.DispatchCtx(c.Req.Context(), cmd)
|
||||
err = bus.Dispatch(c.Req.Context(), cmd)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to delete datasource", err)
|
||||
}
|
||||
@@ -191,7 +191,7 @@ func (hs *HTTPServer) DeleteDataSourceByUID(c *models.ReqContext) response.Respo
|
||||
|
||||
cmd := &models.DeleteDataSourceCommand{UID: uid, OrgID: c.OrgId}
|
||||
|
||||
err = bus.DispatchCtx(c.Req.Context(), cmd)
|
||||
err = bus.Dispatch(c.Req.Context(), cmd)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to delete datasource", err)
|
||||
}
|
||||
@@ -212,7 +212,7 @@ func (hs *HTTPServer) DeleteDataSourceByName(c *models.ReqContext) response.Resp
|
||||
}
|
||||
|
||||
getCmd := &models.GetDataSourceQuery{Name: name, OrgId: c.OrgId}
|
||||
if err := bus.DispatchCtx(c.Req.Context(), getCmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), getCmd); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (hs *HTTPServer) DeleteDataSourceByName(c *models.ReqContext) response.Resp
|
||||
}
|
||||
|
||||
cmd := &models.DeleteDataSourceCommand{Name: name, OrgID: c.OrgId}
|
||||
err := bus.DispatchCtx(c.Req.Context(), cmd)
|
||||
err := bus.Dispatch(c.Req.Context(), cmd)
|
||||
if err != nil {
|
||||
return response.Error(500, "Failed to delete datasource", err)
|
||||
}
|
||||
@@ -260,7 +260,7 @@ func AddDataSource(c *models.ReqContext) response.Response {
|
||||
return resp
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &cmd); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNameExists) || errors.Is(err, models.ErrDataSourceUidExists) {
|
||||
return response.Error(409, err.Error(), err)
|
||||
}
|
||||
@@ -294,7 +294,7 @@ func (hs *HTTPServer) UpdateDataSource(c *models.ReqContext) response.Response {
|
||||
return response.Error(500, "Failed to update datasource", err)
|
||||
}
|
||||
|
||||
err = bus.DispatchCtx(c.Req.Context(), &cmd)
|
||||
err = bus.Dispatch(c.Req.Context(), &cmd)
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceUpdatingOldVersion) {
|
||||
return response.Error(409, "Datasource has already been updated by someone else. Please reload and try again", err)
|
||||
@@ -307,7 +307,7 @@ func (hs *HTTPServer) UpdateDataSource(c *models.ReqContext) response.Response {
|
||||
OrgId: c.OrgId,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
@@ -359,7 +359,7 @@ func getRawDataSourceById(ctx context.Context, id int64, orgID int64) (*models.D
|
||||
OrgId: orgID,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ func getRawDataSourceByUID(ctx context.Context, uid string, orgID int64) (*model
|
||||
OrgId: orgID,
|
||||
}
|
||||
|
||||
if err := bus.DispatchCtx(ctx, &query); err != nil {
|
||||
if err := bus.Dispatch(ctx, &query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ func getRawDataSourceByUID(ctx context.Context, uid string, orgID int64) (*model
|
||||
func GetDataSourceByName(c *models.ReqContext) response.Response {
|
||||
query := models.GetDataSourceQuery{Name: web.Params(c.Req)[":name"], OrgId: c.OrgId}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
@@ -398,7 +398,7 @@ func GetDataSourceByName(c *models.ReqContext) response.Response {
|
||||
func GetDataSourceIdByName(c *models.ReqContext) response.Response {
|
||||
query := models.GetDataSourceQuery{Name: web.Params(c.Req)[":name"], OrgId: c.OrgId}
|
||||
|
||||
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
|
||||
if err := bus.Dispatch(c.Req.Context(), &query); err != nil {
|
||||
if errors.Is(err, models.ErrDataSourceNotFound) {
|
||||
return response.Error(404, "Data source not found", nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user