Chore: Propagate context for quotas (#39205)

Propagate context for quotas and queries/commands.

Ref #36734
This commit is contained in:
Marcus Efraimsson
2021-09-20 17:05:30 +02:00
committed by GitHub
parent fef8e646ea
commit 1e4a660ea7
7 changed files with 222 additions and 211 deletions

View File

@@ -14,7 +14,7 @@ func GetOrgQuotas(c *models.ReqContext) response.Response {
}
query := models.GetOrgQuotasQuery{OrgId: c.ParamsInt64(":orgId")}
if err := bus.Dispatch(&query); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
return response.Error(500, "Failed to get org quotas", err)
}
@@ -32,7 +32,7 @@ func UpdateOrgQuota(c *models.ReqContext, cmd models.UpdateOrgQuotaCmd) response
return response.Error(404, "Invalid quota target", nil)
}
if err := bus.Dispatch(&cmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
return response.Error(500, "Failed to update org quotas", err)
}
return response.Success("Organization quota updated")
@@ -44,7 +44,7 @@ func GetUserQuotas(c *models.ReqContext) response.Response {
}
query := models.GetUserQuotasQuery{UserId: c.ParamsInt64(":id")}
if err := bus.Dispatch(&query); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &query); err != nil {
return response.Error(500, "Failed to get org quotas", err)
}
@@ -62,7 +62,7 @@ func UpdateUserQuota(c *models.ReqContext, cmd models.UpdateUserQuotaCmd) respon
return response.Error(404, "Invalid quota target", nil)
}
if err := bus.Dispatch(&cmd); err != nil {
if err := bus.DispatchCtx(c.Req.Context(), &cmd); err != nil {
return response.Error(500, "Failed to update org quotas", err)
}
return response.Success("Organization quota updated")