Documentation ¶
Overview ¶
Package screenshot is a generated GoMock package.
Package screenshot is a generated GoMock package.
Package screenshot is a generated GoMock package.
Index ¶
- Variables
- type CacheService
- type HeadlessScreenshotService
- type InmemCacheService
- type MockCacheService
- type MockCacheServiceMockRecorder
- type MockRateLimiter
- type MockRateLimiterMockRecorder
- type MockScreenshotService
- type MockScreenshotServiceMockRecorder
- type NoOpCacheService
- type NoOpRateLimiter
- type NoOpScreenshotService
- type RateLimiter
- type Screenshot
- type ScreenshotOptions
- type ScreenshotService
- type ScreenshotUnavailableService
- type TokenRateLimiter
Constants ¶
This section is empty.
Variables ¶
var ( DefaultTheme = models.ThemeDark DefaultTimeout = 15 * time.Second DefaultHeight = 500 DefaultWidth = 1000 )
var (
)Functions ¶
This section is empty.
Types ¶
type CacheService ¶
type CacheService interface { // Get returns the screenshot for the options or false if a screenshot with these // options does not exist. Get(ctx context.Context, opts ScreenshotOptions) (*Screenshot, bool) // Set the screenshot for the options. If another screenshot exists with these // options then it will be replaced. Set(ctx context.Context, opts ScreenshotOptions, screenshot *Screenshot) error }
CacheService caches screenshots.
func NewInmemCacheService ¶
func NewInmemCacheService(expiration time.Duration, r prometheus.Registerer) CacheService
type HeadlessScreenshotService ¶
type HeadlessScreenshotService struct {
// contains filtered or unexported fields
}
HeadlessScreenshotService takes screenshots using a headless browser.
func (*HeadlessScreenshotService) Take ¶
func (s *HeadlessScreenshotService) Take(ctx context.Context, opts ScreenshotOptions) (*Screenshot, error)
Take returns a screenshot of the panel. It returns an error if either the panel, or the dashboard that contains the panel, does not exist, or the screenshot could not be taken due to an error. It uses both the context and the timeout in ScreenshotOptions, however the same context is used for both database queries and the request to the rendering service, while the timeout in ScreenshotOptions is passed to the rendering service where it is used as a client timeout. It is not recommended to pass a context without a deadline and the context deadline should be at least as long as the timeout in ScreenshotOptions.
type InmemCacheService ¶
type InmemCacheService struct {
// contains filtered or unexported fields
}
InmemCacheService is an in-mem screenshot cache.
func (*InmemCacheService) Get ¶
func (s *InmemCacheService) Get(_ context.Context, opts ScreenshotOptions) (*Screenshot, bool)
func (*InmemCacheService) Set ¶
func (s *InmemCacheService) Set(_ context.Context, opts ScreenshotOptions, screenshot *Screenshot) error
type MockCacheService ¶
type MockCacheService struct {
// contains filtered or unexported fields
}
MockCacheService is a mock of CacheService interface.
func NewMockCacheService ¶
func NewMockCacheService(ctrl *gomock.Controller) *MockCacheService
NewMockCacheService creates a new mock instance.
func (*MockCacheService) EXPECT ¶
func (m *MockCacheService) EXPECT() *MockCacheServiceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockCacheService) Get ¶
func (m *MockCacheService) Get(arg0 context.Context, arg1 ScreenshotOptions) (*Screenshot, bool)
Get mocks base method.
func (*MockCacheService) Set ¶
func (m *MockCacheService) Set(arg0 context.Context, arg1 ScreenshotOptions, arg2 *Screenshot) error
Set mocks base method.
type MockCacheServiceMockRecorder ¶
type MockCacheServiceMockRecorder struct {
// contains filtered or unexported fields
}
MockCacheServiceMockRecorder is the mock recorder for MockCacheService.
func (*MockCacheServiceMockRecorder) Get ¶
func (mr *MockCacheServiceMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*MockCacheServiceMockRecorder) Set ¶
func (mr *MockCacheServiceMockRecorder) Set(arg0, arg1, arg2 interface{}) *gomock.Call
Set indicates an expected call of Set.
type MockRateLimiter ¶
type MockRateLimiter struct {
// contains filtered or unexported fields
}
MockRateLimiter is a mock of RateLimiter interface.
func NewMockRateLimiter ¶
func NewMockRateLimiter(ctrl *gomock.Controller) *MockRateLimiter
NewMockRateLimiter creates a new mock instance.
func (*MockRateLimiter) Do ¶
func (m *MockRateLimiter) Do(arg0 context.Context, arg1 ScreenshotOptions, arg2 screenshotFunc) (*Screenshot, error)
Do mocks base method.
func (*MockRateLimiter) EXPECT ¶
func (m *MockRateLimiter) EXPECT() *MockRateLimiterMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockRateLimiterMockRecorder ¶
type MockRateLimiterMockRecorder struct {
// contains filtered or unexported fields
}
MockRateLimiterMockRecorder is the mock recorder for MockRateLimiter.
func (*MockRateLimiterMockRecorder) Do ¶
func (mr *MockRateLimiterMockRecorder) Do(arg0, arg1, arg2 interface{}) *gomock.Call
Do indicates an expected call of Do.
type MockScreenshotService ¶
type MockScreenshotService struct {
// contains filtered or unexported fields
}
MockScreenshotService is a mock of ScreenshotService interface.
func NewMockScreenshotService ¶
func NewMockScreenshotService(ctrl *gomock.Controller) *MockScreenshotService
NewMockScreenshotService creates a new mock instance.
func (*MockScreenshotService) EXPECT ¶
func (m *MockScreenshotService) EXPECT() *MockScreenshotServiceMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockScreenshotService) Take ¶
func (m *MockScreenshotService) Take(arg0 context.Context, arg1 ScreenshotOptions) (*Screenshot, error)
Take mocks base method.
type MockScreenshotServiceMockRecorder ¶
type MockScreenshotServiceMockRecorder struct {
// contains filtered or unexported fields
}
MockScreenshotServiceMockRecorder is the mock recorder for MockScreenshotService.
func (*MockScreenshotServiceMockRecorder) Take ¶
func (mr *MockScreenshotServiceMockRecorder) Take(arg0, arg1 interface{}) *gomock.Call
Take indicates an expected call of Take.
type NoOpCacheService ¶
type NoOpCacheService struct{}
func (*NoOpCacheService) Get ¶
func (s *NoOpCacheService) Get(_ context.Context, _ ScreenshotOptions) (*Screenshot, bool)
func (*NoOpCacheService) Set ¶
func (s *NoOpCacheService) Set(_ context.Context, _ ScreenshotOptions, _ *Screenshot) error
type NoOpRateLimiter ¶
type NoOpRateLimiter struct{}
NoOpRateLimiter is a no-op rate limiter that has no limits.
func (*NoOpRateLimiter) Do ¶
func (b *NoOpRateLimiter) Do(ctx context.Context, opts ScreenshotOptions, fn screenshotFunc) (*Screenshot, error)
type NoOpScreenshotService ¶
type NoOpScreenshotService struct{}
NoOpScreenshotService is a service that takes no-op screenshots.
func (*NoOpScreenshotService) Take ¶
func (s *NoOpScreenshotService) Take(_ context.Context, _ ScreenshotOptions) (*Screenshot, error)
type RateLimiter ¶
type RateLimiter interface { // Do restricts the rate at which screenshots can be taken in parallel via screenshotFunc. // It returns the result of screenshotFunc, or an error if either the context deadline // has been exceeded or the context has been canceled while waiting its turn to call // screenshotFunc. Do(ctx context.Context, opts ScreenshotOptions, fn screenshotFunc) (*Screenshot, error) }
A rate limiter restricts the number of screenshots that can be taken in parallel.
func NewTokenRateLimiter ¶
func NewTokenRateLimiter(n int64) RateLimiter
type Screenshot ¶
type Screenshot struct {
Path string
}
Screenshot represents a path to a screenshot on disk.
type ScreenshotOptions ¶
type ScreenshotOptions struct { DashboardUID string PanelID int64 Width int Height int Theme models.Theme Timeout time.Duration }
ScreenshotOptions are the options for taking a screenshot.
func (ScreenshotOptions) SetDefaults ¶
func (s ScreenshotOptions) SetDefaults() ScreenshotOptions
SetDefaults sets default values for missing or invalid options.
type ScreenshotService ¶
type ScreenshotService interface {
Take(ctx context.Context, opts ScreenshotOptions) (*Screenshot, error)
}
ScreenshotService is an interface for taking screenshots.
func NewHeadlessScreenshotService ¶
func NewHeadlessScreenshotService(ds dashboards.DashboardService, rs rendering.Service, r prometheus.Registerer) ScreenshotService
type ScreenshotUnavailableService ¶
type ScreenshotUnavailableService struct{}
ScreenshotUnavailableService is a service that returns ErrScreenshotsUnavailable.
func (*ScreenshotUnavailableService) Take ¶
func (s *ScreenshotUnavailableService) Take(_ context.Context, _ ScreenshotOptions) (*Screenshot, error)
type TokenRateLimiter ¶
type TokenRateLimiter struct {
// contains filtered or unexported fields
}
TokenRateLimiter is a rate limiter that uses a token bucket of fixed size N.
func (*TokenRateLimiter) Do ¶
func (s *TokenRateLimiter) Do(ctx context.Context, opts ScreenshotOptions, fn screenshotFunc) (*Screenshot, error)