Alerting: Create abstraction for launching transactions and refactor existing transaction management to use it (#46216)

* Remove InTransaction from RuleStore and make it its own interface

* Ensure that ctx-based is clear from name

* Resolve merge conflicts

* Refactor tests to work in terms of the introduced abstraction rather than concrete dbstore
This commit is contained in:
Alexander Weaver
2022-03-15 11:48:42 -05:00
committed by GitHub
parent ecdbcd4941
commit 92716cb602
6 changed files with 72 additions and 18 deletions
+2 -1
View File
@@ -27,6 +27,7 @@ import (
)
type RulerSrv struct {
xactManager store.TransactionManager
store store.RuleStore
DatasourceCache datasources.CacheService
QuotaService *quota.QuotaService
@@ -263,7 +264,7 @@ func (srv RulerSrv) updateAlertRulesInGroup(c *models.ReqContext, namespace *mod
// TODO add create rules authz logic
var groupChanges *changes = nil
err := srv.store.InTransaction(c.Req.Context(), func(tranCtx context.Context) error {
err := srv.xactManager.InTransaction(c.Req.Context(), func(tranCtx context.Context) error {
var err error
groupChanges, err = calculateChanges(tranCtx, srv.store, c.SignedInUser.OrgId, namespace, groupName, rules)
if err != nil {