From 5db1a2e804de5a7e94697ff2d958ac8720d0f139 Mon Sep 17 00:00:00 2001 From: idafurjes <36131195+idafurjes@users.noreply.github.com> Date: Tue, 22 Mar 2022 15:43:53 +0100 Subject: [PATCH] Add DB interface (#46832) --- pkg/server/wire.go | 3 +++ pkg/services/sqlstore/db/db.go | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 pkg/services/sqlstore/db/db.go diff --git a/pkg/server/wire.go b/pkg/server/wire.go index fb63d413755..4d018369bd4 100644 --- a/pkg/server/wire.go +++ b/pkg/server/wire.go @@ -66,6 +66,7 @@ import ( "github.com/grafana/grafana/pkg/services/rendering" "github.com/grafana/grafana/pkg/services/schemaloader" "github.com/grafana/grafana/pkg/services/search" + "github.com/grafana/grafana/pkg/services/searchV2" "github.com/grafana/grafana/pkg/services/secrets" secretsDatabase "github.com/grafana/grafana/pkg/services/secrets/database" @@ -74,6 +75,7 @@ import ( serviceaccountsmanager "github.com/grafana/grafana/pkg/services/serviceaccounts/manager" "github.com/grafana/grafana/pkg/services/shorturls" "github.com/grafana/grafana/pkg/services/sqlstore" + "github.com/grafana/grafana/pkg/services/sqlstore/db" "github.com/grafana/grafana/pkg/services/sqlstore/mockstore" "github.com/grafana/grafana/pkg/services/store" "github.com/grafana/grafana/pkg/services/teamguardian" @@ -238,6 +240,7 @@ var wireSet = wire.NewSet( wire.Bind(new(notifications.WebhookSender), new(*notifications.NotificationService)), wire.Bind(new(notifications.EmailSender), new(*notifications.NotificationService)), wire.Bind(new(sqlstore.Store), new(*sqlstore.SQLStore)), + wire.Bind(new(db.DB), new(*sqlstore.SQLStore)), ) var wireTestSet = wire.NewSet( diff --git a/pkg/services/sqlstore/db/db.go b/pkg/services/sqlstore/db/db.go new file mode 100644 index 00000000000..d8b13f809c1 --- /dev/null +++ b/pkg/services/sqlstore/db/db.go @@ -0,0 +1,12 @@ +package db + +import ( + "context" + + "github.com/grafana/grafana/pkg/services/sqlstore" +) + +type DB interface { + WithTransactionalDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error + WithDbSession(ctx context.Context, callback sqlstore.DBTransactionFunc) error +}