Migrate to Wire for dependency injection (#32289)

Fixes #30144

Co-authored-by: dsotirakis <sotirakis.dim@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: spinillos <selenepinillos@gmail.com>
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
This commit is contained in:
Arve Knudsen
2021-08-25 15:11:22 +02:00
committed by GitHub
parent e61bc33163
commit 78596a6756
180 changed files with 2384 additions and 2401 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/grafana/grafana-plugin-sdk-go/data/sqlutil"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util/errutil"
@ -18,26 +17,21 @@ import (
"github.com/grafana/grafana/pkg/tsdb/sqleng"
)
func init() {
registry.Register(&registry.Descriptor{
Name: "PostgresService",
InitPriority: registry.Low,
Instance: &PostgresService{},
})
func ProvideService(cfg *setting.Cfg) *PostgresService {
logger := log.New("tsdb.postgres")
return &PostgresService{
Cfg: cfg,
logger: logger,
tlsManager: newTLSManager(logger, cfg.DataPath),
}
}
type PostgresService struct {
Cfg *setting.Cfg `inject:""`
Cfg *setting.Cfg
logger log.Logger
tlsManager tlsSettingsProvider
}
func (s *PostgresService) Init() error {
s.logger = log.New("tsdb.postgres")
s.tlsManager = newTLSManager(s.logger, s.Cfg.DataPath)
return nil
}
//nolint: staticcheck // plugins.DataPlugin deprecated
func (s *PostgresService) NewExecutor(datasource *models.DataSource) (plugins.DataPlugin, error) {
s.logger.Debug("Creating Postgres query endpoint")