commands

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const OperationKeyCPUReading = "CPUReading"

OperationKeyCPUReading represents the key for the Operation field of an CPUReadingError

Variables

This section is empty.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	TimeInMilSec int
	ReadCPUStat  func(interval time.Duration, percpu bool) ([]float64, error)
}

CPU holds the config to get the cpu load in percentage

func NewCPU

func NewCPU() CPU

NewCPU creates a new cpu percentage struct

func (CPU) Exec

func (c CPU) Exec(args args.Arguments) ([]byte, error)

Exec gets the cpu value and maps it to the executiondata struct

type Disk

type Disk struct {
	ReadDiskStats func(string) (*goDisk.UsageStat, error)
}

Disk the struct for the DI to compose the disk space reader

func NewDisk

func NewDisk() Disk

NewDisk is a ctor for the Disk struct

func (Disk) Exec

func (d Disk) Exec(args args.Arguments) ([]byte, error)

Exec gets the disk space value for the root partition and maps it to the executiondata struct

type Executor

type Executor interface {
	// Exec executes something and returns the result as a byte array of json and an error if something unexpected happened.
	Exec(args.Arguments) ([]byte, error)
}

Executor is a functional interface to execute a command and return the result as a json string ([]byte).

type Mem

type Mem struct {
	ReadVirtualMemoryStat func() (*mem.VirtualMemoryStat, error)
}

Mem holds the memory usage for the json transformation

func NewMem

func NewMem() Mem

NewMem is a constructor for the Mem struct

func (Mem) Exec

func (m Mem) Exec(args args.Arguments) ([]byte, error)

Exec gets the mem value and maps it to the executiondata struct

type Process

type Process struct {
	Pid        int32
	Name       func() (string, error)
	CPUPercent func() (float64, error)
}

Process is an adapter struct for the external process struct from github.com/shirou/gopsutil/process

type Processes

type Processes struct {
	ReadProcesses func() ([]*Process, error)
}

Processes holds the function to get the process list

func NewProcesses

func NewProcesses() Processes

NewProcesses is a factory ctor to build a Processes struct

func (Processes) Exec

func (p Processes) Exec(args args.Arguments) ([]byte, error)

Exec is the implementation of the execution interface to be able to be used as a command

type Result

type Result struct {
	args.Arguments
	Collection collection
}

Result gethers all the results for all commands

func NewResult

func NewResult(a args.Arguments) Result

NewResult creates new result struct

func (Result) ExecCommands

func (r Result) ExecCommands(executors []Executor) Result

ExecCommands runs all commands

func (Result) ResultEquals

func (r Result) ResultEquals(otherResult Result) bool

ResultEquals checks for field equality

Jump to

Keyboard shortcuts

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