dashboard

package
v2.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Screenshot added in v2.3.0

func Screenshot(ctx context.Context, name string) (string, error)

Types

type Action added in v2.2.1

type Action func(ctx context.Context) error

Action is just a function that does something.

type Config

type Config struct {
	// Interval is the minimum interval between fetches.
	Interval time.Duration `json:"interval"`
	// Jitter is the maximum interval between fetches.
	Jitter time.Duration `json:"jitter"`
	// Trace is whether to trace the requests.
	Trace bool `json:"trace"`
	// Logger is the logger to use.
	Logger slog.Logger `json:"-"`
	// Headless controls headless mode for chromedp.
	Headless bool `json:"headless"`
	// ActionFunc is a function that returns an action to run.
	ActionFunc func(ctx context.Context, log slog.Logger, randIntn func(int) int, deadline time.Time) (Label, Action, error) `json:"-"`
	// WaitLoaded is a function that waits for the page to be loaded.
	WaitLoaded func(ctx context.Context, deadline time.Time) error
	// Screenshot is a function that takes a screenshot.
	Screenshot func(ctx context.Context, filename string) (string, error)
	// RandIntn is a function that returns a random number between 0 and n-1.
	RandIntn func(int) int `json:"-"`
}

func (Config) Validate

func (c Config) Validate() error

type Label added in v2.2.1

type Label string

Label identifies an action.

type Metrics

type Metrics interface {
	ObserveDuration(action string, d time.Duration)
	IncErrors(action string)
}

type PromMetrics

type PromMetrics struct {
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(reg prometheus.Registerer) *PromMetrics

func (*PromMetrics) IncErrors

func (p *PromMetrics) IncErrors(action string)

func (*PromMetrics) ObserveDuration

func (p *PromMetrics) ObserveDuration(action string, d time.Duration)

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(client *codersdk.Client, metrics Metrics, cfg Config) *Runner

func (*Runner) Cleanup

func (*Runner) Cleanup(_ context.Context, _ string, _ io.Writer) error

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, _ string, _ io.Writer) error

type Selector added in v2.2.1

type Selector string

Selector locates an element on a page.

type Target added in v2.2.1

type Target struct {
	// Label is a human-readable label for the target.
	Label Label
	// ClickOn is the selector that locates the element to be clicked.
	ClickOn Selector
	// WaitFor is a selector that is expected to appear after the target is clicked.
	WaitFor Selector
}

Target is a thing that can be clicked.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL