Chore: Remove bus.Bus field (#47695) (#47704)

* Chore: Remove bus.Bus field

* fix integration test

(cherry picked from commit e86b6662a1)

Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-04-13 13:11:20 -04:00
committed by GitHub
parent 5332a2db05
commit f01f1073b8
38 changed files with 70 additions and 204 deletions
+4 -7
View File
@@ -15,7 +15,6 @@ import (
_ "github.com/lib/pq"
"xorm.io/xorm"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/infra/fs"
"github.com/grafana/grafana/pkg/infra/localcache"
"github.com/grafana/grafana/pkg/infra/log"
@@ -44,7 +43,6 @@ type ContextSessionKey struct{}
type SQLStore struct {
Cfg *setting.Cfg
Bus bus.Bus
CacheService *localcache.CacheService
dbCfg DatabaseConfig
@@ -56,12 +54,12 @@ type SQLStore struct {
tracer tracing.Tracer
}
func ProvideService(cfg *setting.Cfg, cacheService *localcache.CacheService, bus bus.Bus, migrations registry.DatabaseMigrator, tracer tracing.Tracer) (*SQLStore, error) {
func ProvideService(cfg *setting.Cfg, cacheService *localcache.CacheService, migrations registry.DatabaseMigrator, tracer tracing.Tracer) (*SQLStore, error) {
// This change will make xorm use an empty default schema for postgres and
// by that mimic the functionality of how it was functioning before
// xorm's changes above.
xorm.DefaultPostgresSchema = ""
s, err := newSQLStore(cfg, cacheService, bus, nil, migrations, tracer)
s, err := newSQLStore(cfg, cacheService, nil, migrations, tracer)
if err != nil {
return nil, err
}
@@ -81,11 +79,10 @@ func ProvideServiceForTests(migrations registry.DatabaseMigrator) (*SQLStore, er
return initTestDB(migrations, InitTestDBOpt{EnsureDefaultOrgAndUser: true})
}
func newSQLStore(cfg *setting.Cfg, cacheService *localcache.CacheService, b bus.Bus, engine *xorm.Engine,
func newSQLStore(cfg *setting.Cfg, cacheService *localcache.CacheService, engine *xorm.Engine,
migrations registry.DatabaseMigrator, tracer tracing.Tracer, opts ...InitTestDBOpt) (*SQLStore, error) {
ss := &SQLStore{
Cfg: cfg,
Bus: b,
CacheService: cacheService,
log: log.New("sqlstore"),
skipEnsureDefaultOrgAndUser: false,
@@ -543,7 +540,7 @@ func initTestDB(migration registry.DatabaseMigrator, opts ...InitTestDBOpt) (*SQ
if err != nil {
return nil, err
}
testSQLStore, err = newSQLStore(cfg, localcache.New(5*time.Minute, 10*time.Minute), bus.GetBus(), engine, migration, tracer, opts...)
testSQLStore, err = newSQLStore(cfg, localcache.New(5*time.Minute, 10*time.Minute), engine, migration, tracer, opts...)
if err != nil {
return nil, err
}