mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 20:54:22 -06:00
e822c8a24d
* Use SDK contracts for cloudmonitoring * Get build running, tests passing and do some refactoring (#38754) * fix build+tests and refactor * remove alerting stuff * remove unused field * fix plugin fetch * end to end * resp rename * tidy annotations * reformatting * update refID * reformat imports * fix styling * clean up unmarshalling * uncomment + fix tests * appease linter * remove spaces * remove old cruft * add check for empty queries * update tests * remove pm as dep * adjust proxy route contract * fix service loading * use UNIX val * fix endpoint + resp * h@ckz for frontend * fix resp * fix interval * always set custom meta * remove unused param * fix labels fetch * fix linter * fix test + remove unused field * apply pr feedback * fix grafana-auto intervals * fix tests * resolve conflicts * fix bad merge * fix conflicts * remove bad logger import Co-authored-by: Will Browne <wbrowne@users.noreply.github.com> Co-authored-by: Will Browne <will.browne@grafana.com>
44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package tsdb
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
|
"github.com/grafana/grafana/pkg/services/datasources"
|
|
"github.com/grafana/grafana/pkg/services/oauthtoken"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
_ "github.com/grafana/grafana/pkg/tsdb/postgres"
|
|
)
|
|
|
|
// NewService returns a new Service.
|
|
func NewService(
|
|
cfg *setting.Cfg, backendPluginManager backendplugin.Manager,
|
|
oauthTokenService *oauthtoken.Service, dataSourcesService *datasources.Service) *Service {
|
|
return newService(cfg, backendPluginManager, oauthTokenService, dataSourcesService)
|
|
}
|
|
|
|
func newService(cfg *setting.Cfg, backendPluginManager backendplugin.Manager,
|
|
oauthTokenService oauthtoken.OAuthTokenService, dataSourcesService *datasources.Service) *Service {
|
|
return &Service{
|
|
Cfg: cfg,
|
|
BackendPluginManager: backendPluginManager,
|
|
OAuthTokenService: oauthTokenService,
|
|
DataSourcesService: dataSourcesService,
|
|
}
|
|
}
|
|
|
|
// Service handles data requests to data sources.
|
|
type Service struct {
|
|
Cfg *setting.Cfg
|
|
BackendPluginManager backendplugin.Manager
|
|
OAuthTokenService oauthtoken.OAuthTokenService
|
|
DataSourcesService *datasources.Service
|
|
}
|
|
|
|
//nolint: staticcheck // plugins.DataPlugin deprecated
|
|
func (s *Service) HandleRequest(ctx context.Context, ds *models.DataSource, query plugins.DataQuery) (plugins.DataResponse, error) {
|
|
return dataPluginQueryAdapter(ds.Type, s.BackendPluginManager, s.OAuthTokenService, s.DataSourcesService).DataQuery(ctx, ds, query)
|
|
}
|