mirror of
https://github.com/grafana/grafana.git
synced 2025-01-19 13:03:32 -06:00
Rendering: makes sure IsAvailable can be used during init of other services (#23817)
* Rendering: makes sure service knows if it is configured after Init() * Rendering: refactor
This commit is contained in:
parent
0284747c88
commit
ebdbb0c96d
@ -22,7 +22,11 @@ import (
|
||||
|
||||
func init() {
|
||||
remotecache.Register(&RenderUser{})
|
||||
registry.RegisterService(&RenderingService{})
|
||||
registry.Register(®istry.Descriptor{
|
||||
Name: "RenderingService",
|
||||
Instance: &RenderingService{},
|
||||
InitPriority: registry.High,
|
||||
})
|
||||
}
|
||||
|
||||
const renderKeyPrefix = "render-%s"
|
||||
@ -68,7 +72,7 @@ func (rs *RenderingService) Init() error {
|
||||
}
|
||||
|
||||
func (rs *RenderingService) Run(ctx context.Context) error {
|
||||
if rs.Cfg.RendererUrl != "" {
|
||||
if rs.remoteAvailable() {
|
||||
rs.log = rs.log.New("renderer", "http")
|
||||
rs.log.Info("Backend rendering via external http server")
|
||||
rs.renderAction = rs.renderViaHttp
|
||||
@ -76,7 +80,7 @@ func (rs *RenderingService) Run(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if plugins.Renderer != nil {
|
||||
if rs.pluginAvailable() {
|
||||
rs.log = rs.log.New("renderer", "plugin")
|
||||
rs.pluginInfo = plugins.Renderer
|
||||
|
||||
@ -97,8 +101,16 @@ func (rs *RenderingService) Run(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rs *RenderingService) pluginAvailable() bool {
|
||||
return plugins.Renderer != nil
|
||||
}
|
||||
|
||||
func (rs *RenderingService) remoteAvailable() bool {
|
||||
return rs.Cfg.RendererUrl != ""
|
||||
}
|
||||
|
||||
func (rs *RenderingService) IsAvailable() bool {
|
||||
return rs.renderAction != nil
|
||||
return rs.remoteAvailable() || rs.pluginAvailable()
|
||||
}
|
||||
|
||||
func (rs *RenderingService) RenderErrorImage(err error) (*RenderResult, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user