mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
12
pkg/services/ngalert/store/transactions.go
Normal file
12
pkg/services/ngalert/store/transactions.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user