Backend Plugins: Refactor backend plugin registration and start (#21452)
Moves the details of loading plugins into the backend plugin manager from the respective plugin (datasource, transform and renderer).
This commit is contained in:
@@ -41,17 +41,30 @@ func newClientConfig(executablePath string, logger log.Logger, versionedPlugins
|
||||
}
|
||||
}
|
||||
|
||||
// LegacyStartFunc callback function called when a plugin with old plugin protocol is started.
|
||||
type LegacyStartFunc func(pluginID string, client *LegacyClient, logger log.Logger) error
|
||||
|
||||
// StartFunc callback function called when a plugin with current plugin protocol version is started.
|
||||
type StartFunc func(pluginID string, client *Client, logger log.Logger) error
|
||||
|
||||
// PluginStartFuncs functions called for plugin when started.
|
||||
type PluginStartFuncs struct {
|
||||
OnLegacyStart LegacyStartFunc
|
||||
OnStart StartFunc
|
||||
}
|
||||
|
||||
// PluginDescriptor descriptor used for registering backend plugins.
|
||||
type PluginDescriptor struct {
|
||||
pluginID string
|
||||
executablePath string
|
||||
managed bool
|
||||
versionedPlugins map[int]plugin.PluginSet
|
||||
startFns PluginStartFuncs
|
||||
}
|
||||
|
||||
// NewBackendPluginDescriptor creates a new backend plugin descriptor
|
||||
// used for registering a backend datasource plugin.
|
||||
func NewBackendPluginDescriptor(pluginID, executablePath string) PluginDescriptor {
|
||||
func NewBackendPluginDescriptor(pluginID, executablePath string, startFns PluginStartFuncs) PluginDescriptor {
|
||||
return PluginDescriptor{
|
||||
pluginID: pluginID,
|
||||
executablePath: executablePath,
|
||||
@@ -65,12 +78,13 @@ func NewBackendPluginDescriptor(pluginID, executablePath string) PluginDescripto
|
||||
"transform": &backend.TransformGRPCPlugin{},
|
||||
},
|
||||
},
|
||||
startFns: startFns,
|
||||
}
|
||||
}
|
||||
|
||||
// NewRendererPluginDescriptor creates a new renderer plugin descriptor
|
||||
// used for registering a backend renderer plugin.
|
||||
func NewRendererPluginDescriptor(pluginID, executablePath string) PluginDescriptor {
|
||||
func NewRendererPluginDescriptor(pluginID, executablePath string, startFns PluginStartFuncs) PluginDescriptor {
|
||||
return PluginDescriptor{
|
||||
pluginID: pluginID,
|
||||
executablePath: executablePath,
|
||||
@@ -80,5 +94,18 @@ func NewRendererPluginDescriptor(pluginID, executablePath string) PluginDescript
|
||||
pluginID: &rendererV1.RendererPluginImpl{},
|
||||
},
|
||||
},
|
||||
startFns: startFns,
|
||||
}
|
||||
}
|
||||
|
||||
// LegacyClient client for communicating with a plugin using the old plugin protocol.
|
||||
type LegacyClient struct {
|
||||
DatasourcePlugin datasourceV1.DatasourcePlugin
|
||||
RendererPlugin rendererV1.RendererPlugin
|
||||
}
|
||||
|
||||
// Client client for communicating with a plugin using the current plugin protocol.
|
||||
type Client struct {
|
||||
BackendPlugin backend.BackendPlugin
|
||||
TransformPlugin backend.TransformPlugin
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user