2018-05-24 15:26:27 +02:00
|
|
|
package rendering
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var ErrTimeout = errors.New("Timeout error. You can set timeout in seconds with &timeout url parameter")
|
|
|
|
|
var ErrNoRenderer = errors.New("No renderer plugin found nor is an external render server configured")
|
2018-06-07 15:15:13 +02:00
|
|
|
var ErrPhantomJSNotInstalled = errors.New("PhantomJS executable not found")
|
2018-05-24 15:26:27 +02:00
|
|
|
|
|
|
|
|
type Opts struct {
|
2020-04-21 16:16:41 +02:00
|
|
|
Width int
|
|
|
|
|
Height int
|
|
|
|
|
Timeout time.Duration
|
|
|
|
|
OrgId int64
|
|
|
|
|
UserId int64
|
|
|
|
|
OrgRole models.RoleType
|
|
|
|
|
Path string
|
|
|
|
|
Encoding string
|
|
|
|
|
Timezone string
|
|
|
|
|
ConcurrentLimit int
|
|
|
|
|
DeviceScaleFactor float64
|
|
|
|
|
Headers map[string][]string
|
2018-05-24 15:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type RenderResult struct {
|
2019-11-20 09:26:59 +01:00
|
|
|
FilePath string
|
2018-05-24 15:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-19 19:47:39 +01:00
|
|
|
type renderFunc func(ctx context.Context, renderKey string, options Opts) (*RenderResult, error)
|
2018-05-24 15:26:27 +02:00
|
|
|
|
|
|
|
|
type Service interface {
|
2020-04-15 22:17:41 +02:00
|
|
|
IsAvailable() bool
|
2018-05-24 15:26:27 +02:00
|
|
|
Render(ctx context.Context, opts Opts) (*RenderResult, error)
|
2019-11-18 16:58:15 +01:00
|
|
|
RenderErrorImage(error error) (*RenderResult, error)
|
2020-02-19 19:47:39 +01:00
|
|
|
GetRenderUser(key string) (*RenderUser, bool)
|
2018-05-24 15:26:27 +02:00
|
|
|
}
|