Documentation ¶
Index ¶
- Constants
- func RunModeCLI(checkGroups *CheckSuites, conf *ConfRunner, output io.Writer, ...) int
- func RunModeHTTP(checkGroups *CheckSuites, conf *ConfRunner, logger *log.Logger) int
- type Check
- type CheckDial
- type CheckFile
- type CheckSuites
- type Conf
- type ConfCheckSpec
- type ConfCheckSpecSuites
- type ConfRunner
- type ConfRunners
- type FileType
- type Result
- type Runner
- type Status
- type TimedCheck
Constants ¶
const ExConfig = 78
ExConfig exit code when invlaid configurations
const ExDataErr = 65
ExDataErr exit code for invalid data
const ExNoInput = 72
ExNoInput exit code for when no input provided
const ExOK = 0
ExOK exit code for successful run
const ExSoftware = 70
ExSoftware generic failure exit code
const ExTempFail = 75
ExTempFail exit code when a runtime error
const ( // ShutdownTimeout is the time to wait for server to shutdown ShutdownTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func RunModeCLI ¶
func RunModeCLI(checkGroups *CheckSuites, conf *ConfRunner, output io.Writer, logger *log.Logger) int
RunModeCLI run app in CLI mode using the provided configs, return exit code
func RunModeHTTP ¶
func RunModeHTTP(checkGroups *CheckSuites, conf *ConfRunner, logger *log.Logger) int
RunModeHTTP runs app in http server mode using the provided config, return exit code
Types ¶
type Check ¶
Check is the interface that all checks implement
func CheckFromSpec ¶
func CheckFromSpec(spec *ConfCheckSpec) (Check, error)
CheckFromSpec creates a check from a given ConfCheckSpec
type CheckDial ¶
type CheckDial struct { Network string Address string Absent bool // contains filtered or unexported fields }
CheckDial checks for a net resource by dialing
func CheckDialFromSpec ¶
func CheckDialFromSpec(spec *ConfCheckSpec) (*CheckDial, error)
CheckDialFromSpec creates a CheckDial from a ConfCheckSpec
func NewCheckDial ¶
func NewCheckDial() *CheckDial
NewCheckDial returns a checkDial for local http availability by default
func (*CheckDial) GetTimeout ¶
GetTimeout gets the max duration for the check to timeout
func (*CheckDial) SetTimeout ¶
SetTimeout sets the max duration for the check to timeout
type CheckFile ¶
type CheckFile struct {
// contains filtered or unexported fields
}
CheckFile checks for file/dir existence/type/uid/gid/size
func CheckFileFromSpec ¶
func CheckFileFromSpec(spec *ConfCheckSpec) (*CheckFile, error)
CheckFileFromSpec creates a CheckFile from a ConfCheckSpec
func NewCheckFile ¶
NewCheckFile returns a new checkFile without a uid/gid/size checks
type CheckSuites ¶
CheckSuites is list of checks, grouped by suite name
func CheckSuitesFromSpecSuites ¶
func CheckSuitesFromSpecSuites(specSuites ConfCheckSpecSuites) (CheckSuites, error)
CheckSuitesFromSpecSuites creates checksuites from config check spec suites
type Conf ¶
type Conf struct { Runners ConfRunners CheckSuites ConfCheckSpecSuites `yaml:"check_suites"` }
Conf is app configurations struct
type ConfCheckSpec ¶
type ConfCheckSpec struct { Type string Path string Mode *uint32 User *string Group *string MinSize int32 `yaml:"min_size"` MaxSize *int64 `yaml:"max_size"` Absent bool Network string Address string Timeout time.Duration }
ConfCheckSpec is the spec for each check configuration
type ConfCheckSpecSuites ¶
type ConfCheckSpecSuites map[string][]ConfCheckSpec
ConfCheckSpecSuites is list of ConfCheckSpec grouped by name
type ConfRunner ¶
type ConfRunner struct { Timeout *time.Duration ShutdownSignalHeader *string `yaml:"shutdown_signal_header"` MaxHeaderBytes *int `yaml:"max_header_bytes"` MaxConcurrentRequests *int `yaml:"max_concurrent_requests"` ListenAddress string `yaml:"listen_address"` RequestReadTimeout *time.Duration `yaml:"request_read_timeout"` RequestRequiredHeaders map[string]string `yaml:"request_required_headers"` ResponseWriteTimeout *time.Duration `yaml:"response_write_timeout"` ResponseOK *string `yaml:"response_ok"` ResponseFailed *string `yaml:"response_failed"` ResponseTimeout *string `yaml:"response_timeout"` ResponseInvalidRequest *string `yaml:"response_invalid_request"` }
ConfRunner is config for the check runners
func CopyConfRunner ¶
func CopyConfRunner(conf *ConfRunner) ConfRunner
CopyConfRunner returns a copy of the ConfRunner with the same values
func GetBaseConfRunner ¶
func GetBaseConfRunner() ConfRunner
GetBaseConfRunner returns a base ConfRunner with default literal values
func GetConfRunner ¶
func GetConfRunner(runners *ConfRunners, name string) (ConfRunner, bool)
GetConfRunner returns the runner config for the name merged with the default, and bool if it exists
func GetDefaultConfRunner ¶
func GetDefaultConfRunner(runners *ConfRunners) ConfRunner
GetDefaultConfRunner returns a ConfRunner based on the default configuration
func MergedConfRunners ¶
func MergedConfRunners(baseConf, overrideConf *ConfRunner) ConfRunner
MergedConfRunners merges the baseConf with the overrideConf and returns the merged ConfRunner
type ConfRunners ¶
type ConfRunners map[string]ConfRunner
ConfRunners is a map of runner name to its config ConfRunner
type Runner ¶
Runner runs all the checks logging details
func (*Runner) RunChecks ¶
func (r *Runner) RunChecks(suites CheckSuites) []Check
RunChecks runs all the checks in the suite and returns slice of check