Documentation
¶
Overview ¶
Copyright © 2024 Hugo Haas <[email protected]>
Index ¶
Constants ¶
View Source
const ( AppName = "upd" AppShort = "Tool to monitor if the network connection is up." )
View Source
const ( ConfigConfig string = "config" ConfigDebug string = "debug" ConfigDump string = "dump" )
View Source
const BackoffFactor = 1.5
View Source
const (
DefaultConfig string = ".upd.yaml"
)
Variables ¶
View Source
var ConfigFileUsed string //nolint:gochecknoglobals
View Source
var ErrDownActionRunning = errors.New("cannot start new DownAction when one is already running")
View Source
var ErrNoCommand = errors.New("no command to execute")
Functions ¶
Types ¶
type Checker ¶ added in v1.8.1
type Checker struct{}
func (Checker) ProbeFailure ¶ added in v1.8.1
func (Checker) ProbeSuccess ¶ added in v1.8.1
type Configuration ¶ added in v1.4.0
type Configuration struct {
Checks struct {
Every struct {
Normal int `koanf:"normal" validate:"required,gt=0"`
Down int `koanf:"down" validate:"required,gt=0"`
} `koanf:"everySec"`
List []string `koanf:"list" validate:"required,dive,required,uri"`
TimeOut int `koanf:"timeoutMilli" validate:"required,gt=0"`
Shuffled bool `koanf:"shuffled"`
} `koanf:"checks" validate:"required"`
DownAction struct {
Exec string `koanf:"exec"`
Every struct {
After int `koanf:"after" validate:"omitempty,gt=0"`
Repeat int `koanf:"repeat" validate:"omitempty,gt=0"`
BackoffLimit int `koanf:"expBackoffLimit" validate:"omitempty,gte=0"`
} `koanf:"everySec"`
StopExec string `koanf:"stopExec" validate:"omitempty"`
} `koanf:"downAction" validate:"omitempty"`
LogLevel string `koanf:"logLevel" validate:"omitempty,oneof=trace debug info warn"`
}
func ReadConf ¶
func ReadConf(cfgFile string, printConfig bool) *Configuration
func (Configuration) GetChecks ¶ added in v1.4.0
func (c Configuration) GetChecks() []*pkg.Check
func (Configuration) GetDelays ¶ added in v1.4.0
func (c Configuration) GetDelays() map[bool]time.Duration
func (Configuration) GetDownAction ¶ added in v1.4.0
func (c Configuration) GetDownAction() *DownAction
type DaIteration ¶ added in v1.4.0
type DaIteration struct {
// contains filtered or unexported fields
}
func NewDaIteration ¶ added in v1.5.0
func NewDaIteration() *DaIteration
type DownAction ¶
type DownAction struct {
After time.Duration
Every time.Duration
BackoffLimit time.Duration
Exec string
StopExec string
}
func (*DownAction) NewDownActionLoop ¶ added in v1.5.0
func (da *DownAction) NewDownActionLoop() (*DownActionLoop, context.Context)
func (*DownAction) Start ¶
func (da *DownAction) Start() *DownActionLoop
type DownActionLoop ¶ added in v1.5.0
type DownActionLoop struct {
// contains filtered or unexported fields
}
func (*DownActionLoop) Execute ¶ added in v1.5.0
func (dal *DownActionLoop) Execute(execString string) error
Only return an error if the command cannot be run.
func (*DownActionLoop) Stop ¶ added in v1.5.0
func (dal *DownActionLoop) Stop()
type Loop ¶
type Loop struct {
Checks []*pkg.Check
Delays map[bool]time.Duration
DownAction *DownAction
Shuffle bool
// contains filtered or unexported fields
}
func (*Loop) DownActionStart ¶ added in v1.5.0
func (*Loop) DownActionStop ¶ added in v1.5.0
func (l *Loop) DownActionStop()
func (*Loop) ProcessCheck ¶ added in v1.1.0
Click to show internal directories.
Click to hide internal directories.