SSE: Support for ML query node (#69963)
* introduce a new node-type ML and implement a command outlier that uses ML plugin as a source of data. * add feature flag mlExpressions that guards the feature
This commit is contained in:
+19
-1
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/plugincontext"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
@@ -47,6 +48,9 @@ func NodeTypeFromDatasourceUID(uid string) NodeType {
|
||||
if IsDataSource(uid) {
|
||||
return TypeCMDNode
|
||||
}
|
||||
if uid == MLDatasourceUID {
|
||||
return TypeMLNode
|
||||
}
|
||||
return TypeDatasourceNode
|
||||
}
|
||||
|
||||
@@ -54,7 +58,7 @@ func NodeTypeFromDatasourceUID(uid string) NodeType {
|
||||
type Service struct {
|
||||
cfg *setting.Cfg
|
||||
dataService backend.QueryDataHandler
|
||||
pCtxProvider *plugincontext.Provider
|
||||
pCtxProvider pluginContextProvider
|
||||
features featuremgmt.FeatureToggles
|
||||
|
||||
pluginsClient backend.CallResourceHandler
|
||||
@@ -63,6 +67,11 @@ type Service struct {
|
||||
metrics *metrics
|
||||
}
|
||||
|
||||
type pluginContextProvider interface {
|
||||
Get(ctx context.Context, pluginID string, user *user.SignedInUser, orgID int64) (backend.PluginContext, error)
|
||||
GetWithDataSource(ctx context.Context, pluginID string, user *user.SignedInUser, ds *datasources.DataSource) (backend.PluginContext, error)
|
||||
}
|
||||
|
||||
func ProvideService(cfg *setting.Cfg, pluginClient plugins.Client, pCtxProvider *plugincontext.Provider,
|
||||
features featuremgmt.FeatureToggles, registerer prometheus.Registerer, tracer tracing.Tracer) *Service {
|
||||
return &Service{
|
||||
@@ -117,6 +126,15 @@ func DataSourceModelFromNodeType(kind NodeType) (*datasources.DataSource, error)
|
||||
JsonData: simplejson.New(),
|
||||
SecureJsonData: make(map[string][]byte),
|
||||
}, nil
|
||||
case TypeMLNode:
|
||||
return &datasources.DataSource{
|
||||
ID: mlDatasourceID,
|
||||
UID: MLDatasourceUID,
|
||||
Name: DatasourceUID,
|
||||
Type: mlPluginID,
|
||||
JsonData: simplejson.New(),
|
||||
SecureJsonData: make(map[string][]byte),
|
||||
}, nil
|
||||
case TypeDatasourceNode:
|
||||
return nil, errors.New("cannot create expression data source for data source kind")
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user