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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user