mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 04:12:09 +08:00
Plugins: Remove stream handler from plugins DTO (#63812)
remove stream handler from DTO
This commit is contained in:
@ -114,7 +114,7 @@ func newTestLive(t *testing.T, store db.DB) *live.GrafanaLive {
|
||||
cfg.IsFeatureToggleEnabled = features.IsEnabled
|
||||
gLive, err := live.ProvideService(nil, cfg,
|
||||
routing.NewRouteRegister(),
|
||||
nil, nil, nil,
|
||||
nil, nil, nil, nil,
|
||||
store,
|
||||
nil,
|
||||
&usagestats.UsageStatsMock{T: t},
|
||||
|
@ -55,8 +55,9 @@ type Plugin struct {
|
||||
type PluginDTO struct {
|
||||
JSONData
|
||||
|
||||
logger log.Logger
|
||||
pluginDir string
|
||||
logger log.Logger
|
||||
pluginDir string
|
||||
supportsStreaming bool
|
||||
|
||||
Class Class
|
||||
|
||||
@ -74,13 +75,10 @@ type PluginDTO struct {
|
||||
// SystemJS fields
|
||||
Module string
|
||||
BaseURL string
|
||||
|
||||
// temporary
|
||||
backend.StreamHandler
|
||||
}
|
||||
|
||||
func (p PluginDTO) SupportsStreaming() bool {
|
||||
return p.StreamHandler != nil
|
||||
return p.supportsStreaming
|
||||
}
|
||||
|
||||
func (p PluginDTO) IsApp() bool {
|
||||
@ -367,23 +365,21 @@ type PluginClient interface {
|
||||
}
|
||||
|
||||
func (p *Plugin) ToDTO() PluginDTO {
|
||||
c, _ := p.Client()
|
||||
|
||||
return PluginDTO{
|
||||
logger: p.Logger(),
|
||||
pluginDir: p.PluginDir,
|
||||
JSONData: p.JSONData,
|
||||
Class: p.Class,
|
||||
IncludedInAppID: p.IncludedInAppID,
|
||||
DefaultNavURL: p.DefaultNavURL,
|
||||
Pinned: p.Pinned,
|
||||
Signature: p.Signature,
|
||||
SignatureType: p.SignatureType,
|
||||
SignatureOrg: p.SignatureOrg,
|
||||
SignatureError: p.SignatureError,
|
||||
Module: p.Module,
|
||||
BaseURL: p.BaseURL,
|
||||
StreamHandler: c,
|
||||
logger: p.Logger(),
|
||||
pluginDir: p.PluginDir,
|
||||
JSONData: p.JSONData,
|
||||
Class: p.Class,
|
||||
IncludedInAppID: p.IncludedInAppID,
|
||||
DefaultNavURL: p.DefaultNavURL,
|
||||
Pinned: p.Pinned,
|
||||
Signature: p.Signature,
|
||||
SignatureType: p.SignatureType,
|
||||
SignatureOrg: p.SignatureOrg,
|
||||
SignatureError: p.SignatureError,
|
||||
Module: p.Module,
|
||||
BaseURL: p.BaseURL,
|
||||
supportsStreaming: p.client != nil && p.client.(backend.StreamHandler) != nil,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ type CoreGrafanaScope struct {
|
||||
}
|
||||
|
||||
func ProvideService(plugCtxProvider *plugincontext.Provider, cfg *setting.Cfg, routeRegister routing.RouteRegister,
|
||||
pluginStore plugins.Store, cacheService *localcache.CacheService,
|
||||
pluginStore plugins.Store, pluginClient plugins.Client, cacheService *localcache.CacheService,
|
||||
dataSourceCache datasources.CacheService, sqlStore db.DB, secretsService secrets.Service,
|
||||
usageStatsService usagestats.Service, queryDataService *query.Service, toggles featuremgmt.FeatureToggles,
|
||||
accessControl accesscontrol.AccessControl, dashboardService dashboards.DashboardService, annotationsRepo annotations.Repository,
|
||||
@ -85,6 +85,7 @@ func ProvideService(plugCtxProvider *plugincontext.Provider, cfg *setting.Cfg, r
|
||||
PluginContextProvider: plugCtxProvider,
|
||||
RouteRegister: routeRegister,
|
||||
pluginStore: pluginStore,
|
||||
pluginClient: pluginClient,
|
||||
CacheService: cacheService,
|
||||
DataSourceCache: dataSourceCache,
|
||||
SQLStore: sqlStore,
|
||||
@ -408,6 +409,7 @@ type GrafanaLive struct {
|
||||
SQLStore db.DB
|
||||
SecretsService secrets.Service
|
||||
pluginStore plugins.Store
|
||||
pluginClient plugins.Client
|
||||
queryDataService *query.Service
|
||||
orgService org.Service
|
||||
|
||||
@ -460,7 +462,7 @@ func (g *GrafanaLive) getStreamPlugin(ctx context.Context, pluginID string) (bac
|
||||
return nil, fmt.Errorf("plugin not found: %s", pluginID)
|
||||
}
|
||||
if plugin.SupportsStreaming() {
|
||||
return plugin, nil
|
||||
return g.pluginClient, nil
|
||||
}
|
||||
return nil, fmt.Errorf("%s plugin does not implement StreamHandler: %#v", pluginID, plugin)
|
||||
}
|
||||
|
Reference in New Issue
Block a user