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

View File

@@ -0,0 +1,12 @@
package store
import "context"
// TransactionManager represents the ability to issue and close transactions through contexts.
type TransactionManager interface {
InTransaction(ctx context.Context, work func(ctx context.Context) error) error
}
func (st *DBstore) InTransaction(ctx context.Context, f func(ctx context.Context) error) error {
return st.SQLStore.InTransaction(ctx, f)
}