config

package
v8.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPollStateJSONLog         = "/var/log/trafficcontrol/poll-state.json"
	DefaultConfigFile               = "/etc/trafficcontrol/tc-health-client.json"
	DefaultLogDirectory             = "/var/log/trafficcontrol"
	DefaultLogFile                  = "tc-health-client.log"
	DefaultTOLoginDispersionFactor  = 90
	DefaultTrafficServerConfigDir   = "/opt/trafficserver/etc/trafficserver"
	DefaultTrafficServerBinDir      = "/opt/trafficserver/bin"
	DefaultUnavailablePollThreshold = 2
	DefaultMarkupPollThreshold      = 1
)
View Source
const (
	HealthMethodTrafficMonitor = HealthMethod("traffic-monitor")
	HealthMethodParentL4       = HealthMethod("parent-l4")
	HealthMethodParentL7       = HealthMethod("parent-l7")
	HealthMethodParentService  = HealthMethod("parent-service")
)
View Source
const DefaultMarkdownMinIntervalMS = 5000
View Source
const DefaultParentHealthL4PollMS = 30000
View Source
const DefaultParentHealthL7PollMS = 30000
View Source
const ParentHealthServicePollMS = 30000

Variables

View Source
var DefaultHealthMethods = []HealthMethod{HealthMethodTrafficMonitor}
View Source
var DefaultMarkdownMethods = []HealthMethod{HealthMethodTrafficMonitor}

Functions

func GetTOLoginDispersion

func GetTOLoginDispersion(pollingInterval time.Duration, dispersionFactor int) time.Duration

func LoadConfig

func LoadConfig(cfg *Cfg) (bool, error)

LoadConfig returns whether the config was updated and any error.

Note the cfg may be modified, even if the returned updated is false. Users should create and pass a copy of Cfg if changes on error are not acceptable.

func NewCfgPtr

func NewCfgPtr(cfg *Cfg) *util.AtomicPtr[Cfg]

NewCfgPtr is a convenience func for NewAtomicPtr(cfg).

func ReadCredentials

func ReadCredentials(cfg *Cfg, updating bool) error

*

  • ReadCredentials *
  • cfg - the existing config
  • updating - when true, existing credentials may be updated from the credential file

func Usage

func Usage()

Types

type Cfg

type Cfg struct {
	// TODO fix to not take CDN name, so it can't be wrong.
	//      If this is wrong, the health client runs but just can't find tons of stuff,
	//      resulting in strange not-obvious errors.
	// Infer from server somehow (config header comment? t3c metadata? hostname -s?)
	CDNName                  string `json:"cdn-name"`
	EnableActiveMarkdowns    bool   `json:"enable-active-markdowns"`
	ReasonCode               string `json:"reason-code"`
	TOCredentialFile         string `json:"to-credential-file"`
	TORequestTimeOutSeconds  string `json:"to-request-timeout-seconds"`
	TOPass                   string `json:"to-pass"`
	TOUrl                    string `json:"to-url"`
	TOUser                   string `json:"to-user"`
	TmProxyURL               string `json:"tm-proxy-url"`
	TmPollIntervalSeconds    string `json:"tm-poll-interval-seconds"`
	TOLoginDispersionFactor  int    `json:"to-login-dispersion-factor"`
	UnavailablePollThreshold int    `json:"unavailable-poll-threshold"`
	MarkUpPollThreshold      int    `json:"markup-poll-threshold"`
	TrafficServerConfigDir   string `json:"trafficserver-config-dir"`
	TrafficServerBinDir      string `json:"trafficserver-bin-dir"`
	PollStateJSONLog         string `json:"poll-state-json-log"`
	EnablePollStateLog       bool   `json:"enable-poll-state-log"`
	HealthClientConfigFile   util.ConfigFile
	CredentialFile           util.ConfigFile
	ParsedProxyURL           *url.URL

	MarkdownMinIntervalMS     *uint64 `json:"markdown-min-interval-ms"`
	ParentHealthL4PollMS      uint64  `json:"parent-health-l4-poll-ms"`
	ParentHealthL7PollMS      uint64  `json:"parent-health-l7-poll-ms"`
	ParentHealthServicePollMS uint64  `json:"parent-health-service-poll-ms"`

	// ParentHealthServicePort is the port to serve parent health on. To disable serving parent health, set to 0.
	ParentHealthServicePort int `json:"parent-health-service-port"`

	// ParentHealthLogLocation may be a file path, stdout, stderr, or null (the empty string is equivalent to null)
	ParentHealthLogLocation string `json:"parent-health-log-location"`

	// HealthMethods are the types of health to poll. If omitted, Traffic Monitor health will be used.
	HealthMethods *[]HealthMethod `json:"health-methods"`

	// MarkdownMethods are the types of health to consider when marking down parents.
	// This may be empty or omitted, to never marking down parents.
	MarkdownMethods *[]HealthMethod `json:"markdown-methods"`

	// NumHealthWorkers is the number of worker microthreads (goroutines) per health poll method.
	// Note this only applies to Parent L4, Parent L7, and Parent Service health; the Traffic
	// Monitor health poll is a single HTTP request and thus doesn't need workers.
	NumHealthWorkers int `json:"num-health-workers"`

	// Monitor peers inside strategies.yaml file
	MonitorStrategiesPeers bool `json:"monitor-strategies-peers"`

	TMPollingInterval time.Duration
	TORequestTimeout  time.Duration

	UserAgent string
	// HostName is this host's short hostname.
	// If empty, the system's hostname will be used.
	HostName string
}

func GetConfig

func GetConfig() (*Cfg, error, bool)

func (*Cfg) Clone

func (cfg *Cfg) Clone() *Cfg

type HealthMethod

type HealthMethod string

type LogCfg

type LogCfg struct {
	LogLocationErr   string
	LogLocationDebug string
	LogLocationInfo  string
	LogLocationWarn  string
	LogLocationEvent string
}

func (LogCfg) DebugLog

func (lcfg LogCfg) DebugLog() log.LogLocation

func (LogCfg) ErrorLog

func (lcfg LogCfg) ErrorLog() log.LogLocation

func (LogCfg) EventLog

func (lcfg LogCfg) EventLog() log.LogLocation

func (LogCfg) InfoLog

func (lcfg LogCfg) InfoLog() log.LogLocation

func (LogCfg) WarningLog

func (lcfg LogCfg) WarningLog() log.LogLocation

Jump to

Keyboard shortcuts

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