remove unnecessary state (#32278)

This commit is contained in:
Will Browne 2021-03-29 14:22:56 +02:00 committed by GitHub
parent f37c8c10c5
commit 1d7f155c92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3 additions and 18 deletions

View File

@ -13,9 +13,8 @@ import (
// corePlugin represents a plugin that's part of Grafana core. // corePlugin represents a plugin that's part of Grafana core.
type corePlugin struct { type corePlugin struct {
isDataPlugin bool pluginID string
pluginID string logger log.Logger
logger log.Logger
backend.CheckHealthHandler backend.CheckHealthHandler
backend.CallResourceHandler backend.CallResourceHandler
backend.QueryDataHandler backend.QueryDataHandler
@ -44,10 +43,6 @@ func (cp *corePlugin) Logger() log.Logger {
return cp.logger return cp.logger
} }
func (cp *corePlugin) CanHandleDataQueries() bool {
return cp.isDataPlugin
}
func (cp *corePlugin) DataQuery(ctx context.Context, dsInfo *models.DataSource, func (cp *corePlugin) DataQuery(ctx context.Context, dsInfo *models.DataSource,
tsdbQuery plugins.DataQuery) (plugins.DataResponse, error) { tsdbQuery plugins.DataQuery) (plugins.DataResponse, error) {
// TODO: Inline the adapter, since it shouldn't be necessary // TODO: Inline the adapter, since it shouldn't be necessary
@ -57,7 +52,6 @@ func (cp *corePlugin) DataQuery(ctx context.Context, dsInfo *models.DataSource,
} }
func (cp *corePlugin) Start(ctx context.Context) error { func (cp *corePlugin) Start(ctx context.Context) error {
cp.isDataPlugin = cp.QueryDataHandler != nil
return nil return nil
} }

View File

@ -40,10 +40,6 @@ func newPlugin(descriptor PluginDescriptor) backendplugin.PluginFactoryFunc {
} }
} }
func (p *grpcPlugin) CanHandleDataQueries() bool {
return false
}
func (p *grpcPlugin) PluginID() string { func (p *grpcPlugin) PluginID() string {
return p.descriptor.pluginID return p.descriptor.pluginID
} }

View File

@ -35,7 +35,6 @@ type Plugin interface {
Stop(ctx context.Context) error Stop(ctx context.Context) error
IsManaged() bool IsManaged() bool
Exited() bool Exited() bool
CanHandleDataQueries() bool
backend.CollectMetricsHandler backend.CollectMetricsHandler
backend.CheckHealthHandler backend.CheckHealthHandler
backend.CallResourceHandler backend.CallResourceHandler

View File

@ -115,7 +115,7 @@ func (m *manager) getAWSEnvironmentVariables() []string {
func (m *manager) GetDataPlugin(pluginID string) interface{} { func (m *manager) GetDataPlugin(pluginID string) interface{} {
plugin := m.plugins[pluginID] plugin := m.plugins[pluginID]
if plugin == nil || !plugin.CanHandleDataQueries() { if plugin == nil {
return nil return nil
} }

View File

@ -337,10 +337,6 @@ func (tp *testPlugin) Logger() log.Logger {
return tp.logger return tp.logger
} }
func (tp *testPlugin) CanHandleDataQueries() bool {
return false
}
func (tp *testPlugin) Start(ctx context.Context) error { func (tp *testPlugin) Start(ctx context.Context) error {
tp.mutex.Lock() tp.mutex.Lock()
defer tp.mutex.Unlock() defer tp.mutex.Unlock()