mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Use db.DB interface instead of sqlstore (#54358)
* use db.DB interface instead of sqlstore * make store service depends on db.DB instead of sqlstore
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/db"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
)
|
||||
|
||||
@@ -45,7 +46,7 @@ type fileMeta struct {
|
||||
}
|
||||
|
||||
type dbFileStorage struct {
|
||||
db *sqlstore.SQLStore
|
||||
db db.DB
|
||||
log log.Logger
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ func createContentsHash(contents []byte) string {
|
||||
return hex.EncodeToString(hash[:])
|
||||
}
|
||||
|
||||
func NewDbStorage(log log.Logger, db *sqlstore.SQLStore, filter PathFilter, rootFolder string) FileStorage {
|
||||
func NewDbStorage(log log.Logger, db db.DB, filter PathFilter, rootFolder string) FileStorage {
|
||||
return newWrapper(log, &dbFileStorage{
|
||||
log: log,
|
||||
db: db,
|
||||
@@ -224,7 +225,7 @@ func (s dbFileStorage) Upsert(ctx context.Context, cmd *UpsertFileCommand) error
|
||||
}
|
||||
|
||||
if len(cmd.Properties) != 0 {
|
||||
if err = upsertProperties(s.db.Dialect, sess, now, cmd, pathHash); err != nil {
|
||||
if err = upsertProperties(s.db.GetDialect(), sess, now, cmd, pathHash); err != nil {
|
||||
if rollbackErr := sess.Rollback(); rollbackErr != nil {
|
||||
s.log.Error("failed while rolling back upsert", "path", cmd.Path)
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/quota"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/db"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
@@ -83,7 +83,7 @@ type StorageService interface {
|
||||
}
|
||||
|
||||
type standardStorageService struct {
|
||||
sql *sqlstore.SQLStore
|
||||
sql db.DB
|
||||
tree *nestedTree
|
||||
cfg *GlobalStorageConfig
|
||||
authService storageAuthService
|
||||
@@ -91,7 +91,7 @@ type standardStorageService struct {
|
||||
}
|
||||
|
||||
func ProvideService(
|
||||
sql *sqlstore.SQLStore,
|
||||
sql db.DB,
|
||||
features featuremgmt.FeatureToggles,
|
||||
cfg *setting.Cfg,
|
||||
quotaService quota.Service,
|
||||
@@ -242,7 +242,7 @@ func createSystemBrandingPathFilter() filestorage.PathFilter {
|
||||
}
|
||||
|
||||
func newStandardStorageService(
|
||||
sql *sqlstore.SQLStore,
|
||||
sql db.DB,
|
||||
globalRoots []storageRuntime,
|
||||
initializeOrgStorages func(orgId int64) []storageRuntime,
|
||||
authService storageAuthService,
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/filestorage"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/db"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
)
|
||||
@@ -30,7 +30,7 @@ func getDbStoragePathPrefix(orgId int64, storageName string) string {
|
||||
return filestorage.Join(fmt.Sprintf("%d", orgId), storageName+filestorage.Delimiter)
|
||||
}
|
||||
|
||||
func newSQLStorage(meta RootStorageMeta, prefix string, name string, descr string, cfg *StorageSQLConfig, sql *sqlstore.SQLStore, orgId int64) *rootStorageSQL {
|
||||
func newSQLStorage(meta RootStorageMeta, prefix string, name string, descr string, cfg *StorageSQLConfig, sql db.DB, orgId int64) *rootStorageSQL {
|
||||
if cfg == nil {
|
||||
cfg = &StorageSQLConfig{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user