lib

package
v0.0.0-...-d2219ce Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_HELP_SIZE            = 10
	DEFAULT_LOGS_SIZE            = 15
	DEFAULT_OUTER_PADDING_BOTTOM = 5
	DEFAULT_OUTER_PADDING_LEFT   = 10
	DEFAULT_OUTER_PADDING_RIGHT  = 10
	DEFAULT_OUTER_PADDING_TOP    = 5
	DEFAULT_RESULTS_SIZE         = 75
	DEFAULT_TABLE_PADDING        = 2
)

Defaults for display configs.

View Source
const (
	QUERY_MODE_COMMAND int = iota + 1 // Queries are commands.
	QUERY_MODE_PROFILE                // Queries are PIDs to profile.
)
View Source
const (
	HELP_TEXT = "(ESC) Quit | (Space) Pause | (Tab) Next Display | (n) Next Query"
)

Misc. constants.

Variables

View Source
var (
	ProfileLabels = []string{
		"State",
		"Age (s)",
		"Threads",
		"CPU Usage (%)",
		"Resident Memory (GB)",
		"Virtual Memory (GB)",
		"Swap (GB)",
		"IO Read (MB)",
		"IO Write (MB)",
	} // Labels supplied for profile results.
)

Functions

func AddResult

func AddResult(query, result string, history bool)

Adds a result to the result store based on a string.

func FilterResult

func FilterResult(result storage.Result, labels, filters []string) storage.Result

Creates a result with filtered values.

func FilterSlice

func FilterSlice[T interface{}](in []T, indexes []int) (out []T)

Pick items from an arbitrary slice according to provided indexes. If indexes is empty, it will just return the original slice.

func GetNextSliceRing

func GetNextSliceRing[T comparable](in []T, current T) T

Gets the next element in a slice, with wrap-around if selecting from the last element.

func GetResult

func GetResult(query string) storage.Result

Retrieves a next result.

func GetResultWait

func GetResultWait(query string) (result storage.Result)

Retrieves a next result, waiting for a non-empty return in a non-blocking manner.

func GraphDisplay

func GraphDisplay(query string, filters, labels []string, displayConfig *DisplayConfig)

Creates a graph of results for the results pane.

func Query

func Query(
	queryMode, attempts, delay int,
	queries []string,
	port string,
	history bool,
	resultsReadyChan chan bool,
) (chan bool, map[string]chan bool)

Entrypoint for 'query' mode.

func RawDisplay

func RawDisplay(query string)

Presents raw output.

func Read

func Read(port string) (done chan int)

func RelativePerc

func RelativePerc(limitingPerc, globalRelativePerc int) int

Gives a new percentage based on globalRelativePerc after reducing totality by limiting Perc.

For example, given a three-way percentage split of 80/10/10, this function will return 50 if given the arguments 80 and 10.

func Results

func Results(
	ctx context.Context,
	displayMode DisplayMode,
	query string,
	history bool,
	displayConfig *DisplayConfig,
	inputConfig *Config,
	inputPauseQueryChans map[string]chan bool,
	resultsReadyChan chan bool,
)

Entry-point function for results.

func StreamDisplay

func StreamDisplay(query string, filters, labels []string, displayConfig *DisplayConfig)

Update the results pane with new results as they are generated.

func TableDisplay

func TableDisplay(query string, filters, labels []string, displayConfig *DisplayConfig)

Creates a table of results for the results pane.

func TokenizeResult

func TokenizeResult(result string) (parsedResult []interface{})

Parses a result into tokens for compound storage.

Types

type Config

type Config struct {
	Count, Delay, DisplayMode, Mode int
	Filters, Labels, Queries        []string
	History, Silent                 bool
	LogLevel                        string
	Port                            string
	PrometheusExporterAddr          string
	PushgatewayAddr                 string
}

Shareable configuration. See CLI flags for further details.

func (*Config) SlogLogLevel

func (c *Config) SlogLogLevel() slog.Level

Retrieves an Slog level from a human-readable level string.

type DisplayConfig

type DisplayConfig struct {
	HelpSize, LogsSize, ResultsSize                                          int  // Proportional size of widgets.
	OuterPaddingBottom, OuterPaddingLeft, OuterPaddingRight, OuterPaddingTop int  // Padding for the full display.
	ShowHelp, ShowLogs, ShowStatus                                           bool // Whether or not to show widgets.
	TablePadding                                                             int  // Padding for table cells in table displays.
}

General configuration for display modes.

func NewDisplayConfig

func NewDisplayConfig() *DisplayConfig

Creates a default display config.

type DisplayDriver

type DisplayDriver int

Represents the display driver.

const (
	DISPLAY_RAW      DisplayDriver = iota + 1 // Used for direct output.
	DISPLAY_TVIEW                             // Used when tview is the TUI driver.
	DISPLAY_TERMDASH                          // Used when termdash is the TUI driver.
)

Display driver constants. Each display mode uses a specific display driver.

type DisplayMode

type DisplayMode int

Represents the display mode.

const (
	DISPLAY_MODE_RAW    DisplayMode = iota + 1 // For running in 'raw' display mode.
	DISPLAY_MODE_STREAM                        // For running in 'stream' display mode.
	DISPLAY_MODE_TABLE                         // For running in 'table' display mode.
	DISPLAY_MODE_GRAPH                         // For running in 'graph' display mode.
)

Display mode constants.

Jump to

Keyboard shortcuts

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