mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 18:52:33 +08:00
Backend plugins: Renderer v2 plugin (#23625)
grafana-plugin-model is legacy and is replaced by new backend plugins SDK and architecture. Renderer is not part of SDK and we want to keep it that way for now since it's highly unlikely there will be more than one kind of renderer plugin. So this PR adds support for renderer plugin v2. Also adds support sending a Device Scale Factor parameter to the plugin v2 remote rendering service and by that replaces #22474. Adds support sending a Headers parameter to the plugin v2 and remote rendering service which for now only include Accect-Language header (the user locale in browser when using Grafana), ref grafana/grafana-image-renderer#45. Fixes health check json details response. Adds image renderer plugin configuration settings in defaults.ini and sample.ini. Co-Authored-By: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:

committed by
GitHub

parent
97bb3dcf2d
commit
871ad73414
@ -8,6 +8,7 @@ import (
|
||||
pluginModel "github.com/grafana/grafana-plugin-model/go/renderer"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin"
|
||||
"github.com/grafana/grafana/pkg/plugins/backendplugin/pluginextensionv2"
|
||||
"github.com/grafana/grafana/pkg/util/errutil"
|
||||
)
|
||||
|
||||
@ -15,7 +16,8 @@ type RendererPlugin struct {
|
||||
PluginBase
|
||||
|
||||
Executable string `json:"executable,omitempty"`
|
||||
GrpcPlugin pluginModel.RendererPlugin
|
||||
GrpcPluginV1 pluginModel.RendererPlugin
|
||||
GrpcPluginV2 pluginextensionv2.RendererPlugin
|
||||
backendPluginManager backendplugin.Manager
|
||||
}
|
||||
|
||||
@ -34,6 +36,7 @@ func (r *RendererPlugin) Load(decoder *json.Decoder, pluginDir string, backendPl
|
||||
fullpath := path.Join(r.PluginDir, cmd)
|
||||
descriptor := backendplugin.NewRendererPluginDescriptor(r.Id, fullpath, backendplugin.PluginStartFuncs{
|
||||
OnLegacyStart: r.onLegacyPluginStart,
|
||||
OnStart: r.onPluginStart,
|
||||
})
|
||||
if err := backendPluginManager.Register(descriptor); err != nil {
|
||||
return errutil.Wrapf(err, "Failed to register backend plugin")
|
||||
@ -52,6 +55,11 @@ func (r *RendererPlugin) Start(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func (r *RendererPlugin) onLegacyPluginStart(pluginID string, client *backendplugin.LegacyClient, logger log.Logger) error {
|
||||
r.GrpcPlugin = client.RendererPlugin
|
||||
r.GrpcPluginV1 = client.RendererPlugin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *RendererPlugin) onPluginStart(pluginID string, client *backendplugin.Client, logger log.Logger) error {
|
||||
r.GrpcPluginV2 = client.RendererPlugin
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user