Thanks to visit codestin.com
Credit goes to pkg.go.dev

dashboard

package
v0.27.2-0...-a2d64c0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// MinWait is the minimum interval between fetches.
	MinWait time.Duration `json:"duration_min"`
	// MaxWait is the maximum interval between fetches.
	MaxWait time.Duration `json:"duration_max"`
	// Trace is whether to trace the requests.
	Trace bool `json:"trace"`
	// Logger is the logger to use.
	Logger slog.Logger `json:"-"`
	// RollTable is the set of actions to perform
	RollTable RollTable `json:"roll_table"`
}

func (Config) Validate

func (c Config) Validate() error

type Metrics

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

type Params

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

Params is a set of parameters to pass to the actions in a rollTable.

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) IncStatuses

func (p *PromMetrics) IncStatuses(action string, code string)

func (*PromMetrics) ObserveDuration

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

type RollTable

type RollTable []RollTableEntry

RollTable is a slice of rollTableEntry.

var DefaultActions RollTable = []RollTableEntry{
	{0, fetchWorkspaces, "fetch workspaces"},
	{1, fetchUsers, "fetch users"},
	{2, fetchTemplates, "fetch templates"},
	{3, authCheckAsOwner, "authcheck owner"},
	{4, authCheckAsNonOwner, "authcheck not owner"},
	{5, fetchAuditLog, "fetch audit log"},
	{6, fetchActiveUsers, "fetch active users"},
	{7, fetchSuspendedUsers, "fetch suspended users"},
	{8, fetchTemplateVersion, "fetch template version"},
	{9, fetchWorkspace, "fetch workspace"},
	{10, fetchTemplate, "fetch template"},
	{11, fetchUserByID, "fetch user by ID"},
	{12, fetchUserByUsername, "fetch user by username"},
	{13, fetchWorkspaceBuild, "fetch workspace build"},
	{14, fetchDeploymentConfig, "fetch deployment config"},
	{15, fetchWorkspaceQuotaForUser, "fetch workspace quota for user"},
	{16, fetchDeploymentStats, "fetch deployment stats"},
	{17, fetchWorkspaceLogs, "fetch workspace logs"},
}

DefaultActions is a table of actions to perform. D&D nerds will feel right at home here :-) Note that the order of the table is important! Entries must be in ascending order.

type RollTableEntry

type RollTableEntry struct {
	// Roll is the minimum number required to perform the action.
	Roll int
	// Fn is the function to call.
	Fn func(ctx context.Context, p *Params) error
	// Label is used for logging.
	Label string
}

RollTableEntry is an entry in the roll table.

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) error

func (*Runner) Run

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

Jump to

Keyboard shortcuts

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