controller

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package controller runs Probes, reads time, receives Statuses from Probes, Command from the UI, and computes a View for the app to display.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command int

A Command is used to change the View generated by the controller, by filtering, sorting, or changing display formats.

const (
	// CmdQuit is the command to quit the app
	CmdQuit Command = 0
	// CmdFilterAll is the command to display all Statuses regardless of their Severity
	CmdFilterAll Command = iota
	// CmdFilterNotice is the command to display all Statuses with Severity notice or worse
	CmdFilterNotice Command = iota
	// CmdFilterWarning is the command to display all Statuses with Severity warning or worse
	CmdFilterWarning Command = iota
	// CmdFilterCritical is the command to display all Statuses with Severity critical
	CmdFilterCritical Command = iota
	// CmdSortLastChange is the command to display Statuses from most recent change to oldest or unknown change time
	CmdSortLastChange Command = iota
	// CmdSortSeverity is the command to display Statuses from worse Severity to best Severity.
	CmdSortSeverity Command = iota
	// CmdSortLabel is the command to display Statuses by alphabetical Label.
	CmdSortLabel Command = iota
	// CmdDurationFormat switches between displaying time or duration for Update and Change columns.
	CmdDurationFormat Command = iota
	// CmdClockChoice switches between different clocks with different formats or locations.
	CmdClockChoice Command = iota
)

func (Command) String

func (c Command) String() string

type Controller

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

A Controller tracks the state of the application and outputs a View for the app to display.

func NewController

func NewController(
	cfg configuration.ControllerConfig,
	prc []configuration.ProbeRunnerConfig,
	cmds <-chan Command,
	v chan<- View,
	quitter Quitter,
) *Controller

NewController creates a usable controller from configuration and channel spaghettis.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context)

Run starts the controller, which will run until the provided context is done.

type Quitter

type Quitter func()

Quitter is the function to call in order to quit the app gracefully.

type Row

type Row struct {
	ID          string         // not displayed, from probe
	Severity    model.Severity // min(from probe, from configuration)
	Label       string         // from configuration
	Description string         // from probe
	Update      string         // from probe
	Change      string         // from probe
}

A Row is to be displayed in a table and is a UI representation of a Status.

type View

type View struct {
	ProbeCnt int
	ErrorCnt int
	Filter   model.Severity
	Sort     model.StatusField
	Clock    string
	Rows     []Row
}

A View contains all the informations that an implementation of Kee should display to the user.

Jump to

Keyboard shortcuts

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