Documentation
¶
Overview ¶
Package global is the package for EaseProbe
Index ¶
- Constants
- Variables
- func CommandLine(cmd string, args []string) string
- func DoRetry(kind, name, tag string, r Retry, fn func() error) error
- func EnumMarshalJSON[T comparable](m map[T]string, v T, typename string) ([]byte, error)
- func EnumMarshalYaml[T comparable](m map[T]string, v T, typename string) (interface{}, error)
- func EnumUnmarshalJSON[T comparable](b []byte, m map[string]T, v *T, init T, typename string) error
- func EnumUnmarshalYaml[T comparable](unmarshal func(interface{}) error, m map[string]T, v *T, init T, ...) error
- func EscapeQuote(str string) string
- func FooterString() string
- func GetTimeFormat() string
- func GetTimeLocation() *time.Location
- func GetWorkDir() string
- func InitEaseProbe(name, icon string)
- func InitEaseProbeWithTime(name, icon, tf, tz string)
- func MakeDirectory(filename string) string
- func ReverseMap[K comparable, V comparable](m map[K]V) map[V]K
- func SetTimeFormat(tf string)
- func SetTimeZone(tz string)
- type EaseProbe
- type ErrNoRetry
- type IntervalStrategy
- func (n *IntervalStrategy) IntervalStrategy(s string)
- func (n IntervalStrategy) MarshalJSON() ([]byte, error)
- func (n IntervalStrategy) MarshalYAML() (interface{}, error)
- func (n IntervalStrategy) String() string
- func (n *IntervalStrategy) UnmarshalJSON(data []byte) error
- func (n *IntervalStrategy) UnmarshalYAML(unmarshal func(interface{}) error) error
- type NotificationStrategySettings
- type NotifySettings
- type ProbeSettings
- func (p *ProbeSettings) NormalizeInterval(t time.Duration) time.Duration
- func (p *ProbeSettings) NormalizeNotificationStrategy(t NotificationStrategySettings) NotificationStrategySettings
- func (p *ProbeSettings) NormalizeThreshold(t StatusChangeThresholdSettings) StatusChangeThresholdSettings
- func (p *ProbeSettings) NormalizeTimeOut(t time.Duration) time.Duration
- type Retry
- type StatusChangeThresholdSettings
- type TLS
Constants ¶
const ( // Org is the organization Org = "MegaEase" // DefaultProg is the program name DefaultProg = "EaseProbe" // DefaultIconURL is the default icon which used in Slack or Discord DefaultIconURL = "https://megaease.com/favicon.png" )
const ( // DefaultRetryTimes is 3 times DefaultRetryTimes = 3 // DefaultRetryInterval is 5 seconds DefaultRetryInterval = time.Second * 5 // DefaultTimeFormat is "2006-01-02 15:04:05 Z0700" DefaultTimeFormat = "2006-01-02 15:04:05 Z0700" // DefaultTimeZone is "UTC" DefaultTimeZone = "UTC" // DefaultProbeInterval is 1 minutes DefaultProbeInterval = time.Second * 60 // DefaultTimeOut is 30 seconds DefaultTimeOut = time.Second * 30 // DefaultChannelName is the default wide channel name DefaultChannelName = "__EaseProbe_Channel__" // DefaultStatusChangeThresholdSetting is the threshold of status change DefaultStatusChangeThresholdSetting = 1 // DefaultNotificationStrategy is the default notify strategy DefaultNotificationStrategy = RegularStrategy // DefaultMaxNotificationTimes is the default max notification times DefaultMaxNotificationTimes = 1 // DefaultNotificationFactor is the default notification factor DefaultNotificationFactor = 1 // DefaultConfigFileCheckInterval is the default config file checking interval DefaultConfigFileCheckInterval = time.Second * 5 )
const ( // DefaultHTTPServerIP is the default ip of the HTTP server DefaultHTTPServerIP = "0.0.0.0" // DefaultHTTPServerPort is the default port of the HTTP server DefaultHTTPServerPort = "8181" // DefaultPageSize is the default page size DefaultPageSize = 100 // DefaultAccessLogFile is the default access log file name DefaultAccessLogFile = "access.log" // DefaultDataFile is the default data file name DefaultDataFile = "data/data.yaml" // DefaultPIDFile is the default pid file name DefaultPIDFile = "easeprobe.pid" )
const ( // DefaultMaxLogSize is the default max log size DefaultMaxLogSize = 10 // 10M // DefaultMaxLogAge is the default max log age DefaultMaxLogAge = 7 // 7 days // DefaultMaxBackups is the default backup file number DefaultMaxBackups = 5 // file // DefaultLogCompress is the default compress log DefaultLogCompress = true )
Variables ¶
var ( // Ver is the program version // It will be set by the build script // go build -ldflags "-X github.com/megaease/easegress/pkg/global.Ver=1.0.0" Ver = "v1.7.0" //OrgProg combine organization and program OrgProg = Org + " " + DefaultProg //OrgProgVer combine organization and program and version OrgProgVer = Org + " " + DefaultProg + "/" + Ver )
Functions ¶
func CommandLine ¶
CommandLine will return the whole command line which includes command and all arguments
func EnumMarshalJSON ¶
func EnumMarshalJSON[T comparable](m map[T]string, v T, typename string) ([]byte, error)
EnumMarshalJSON is a help function to marshal the enum to JSON
func EnumMarshalYaml ¶
func EnumMarshalYaml[T comparable](m map[T]string, v T, typename string) (interface{}, error)
EnumMarshalYaml is a help function to marshal the enum to yaml
func EnumUnmarshalJSON ¶
func EnumUnmarshalJSON[T comparable](b []byte, m map[string]T, v *T, init T, typename string) error
EnumUnmarshalJSON is a help function to unmarshal the enum from JSON
func EnumUnmarshalYaml ¶
func EnumUnmarshalYaml[T comparable](unmarshal func(interface{}) error, m map[string]T, v *T, init T, typename string) error
EnumUnmarshalYaml is a help function to unmarshal the enum from yaml
func EscapeQuote ¶
EscapeQuote escape the string the single quote, double quote, and backtick
func FooterString ¶
func FooterString() string
FooterString return the footer string e.g. "EaseProbe v1.0.0 @ localhost"
func InitEaseProbeWithTime ¶
func InitEaseProbeWithTime(name, icon, tf, tz string)
InitEaseProbeWithTime init the EaseProbe with time
func MakeDirectory ¶
MakeDirectory return the writeable filename
func ReverseMap ¶
func ReverseMap[K comparable, V comparable](m map[K]V) map[V]K
ReverseMap just reverse the map from [key, value] to [value, key]
Types ¶
type EaseProbe ¶
type EaseProbe struct { Name string `yaml:"name"` IconURL string `yaml:"icon"` Version string `yaml:"version"` Host string `yaml:"host"` TimeFormat string `yaml:"time_format"` TimeZone string `yaml:"time_zone"` TimeLoc *time.Location `yaml:"-"` }
EaseProbe is the information of the program
type ErrNoRetry ¶
type ErrNoRetry struct {
Message string
}
ErrNoRetry is the error need not retry
func (*ErrNoRetry) Error ¶
func (e *ErrNoRetry) Error() string
type IntervalStrategy ¶
type IntervalStrategy int
IntervalStrategy is the notification strategy
const ( UnknownStrategy IntervalStrategy = iota RegularStrategy // the same period of time between each notification IncrementStrategy // the period of time between each notification is increased by a fixed value ExponentialStrategy // the period of time between each notification is increased exponentially )
The notification strategy enum
func (*IntervalStrategy) IntervalStrategy ¶
func (n *IntervalStrategy) IntervalStrategy(s string)
IntervalStrategy returns the IntervalStrategy value of the string
func (IntervalStrategy) MarshalJSON ¶
func (n IntervalStrategy) MarshalJSON() ([]byte, error)
MarshalJSON is marshal the NotificationIntervalStrategy.
func (IntervalStrategy) MarshalYAML ¶
func (n IntervalStrategy) MarshalYAML() (interface{}, error)
MarshalYAML is marshal the IntervalStrategy.
func (IntervalStrategy) String ¶
func (n IntervalStrategy) String() string
String returns the string value of the NotificationIntervalStrategy
func (*IntervalStrategy) UnmarshalJSON ¶
func (n *IntervalStrategy) UnmarshalJSON(data []byte) error
UnmarshalJSON is unmarshal the NotificationIntervalStrategy.
func (*IntervalStrategy) UnmarshalYAML ¶
func (n *IntervalStrategy) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML is unmarshal the IntervalStrategy.
type NotificationStrategySettings ¶
type NotificationStrategySettings struct { Strategy IntervalStrategy `` /* 226-byte string literal not displayed */ Factor int `` /* 138-byte string literal not displayed */ MaxTimes int `yaml:"max" json:"max" jsonschema:"title=Max Times,description=the max times to send notification,default=1"` }
NotificationStrategySettings is the notification strategy settings
type NotifySettings ¶
NotifySettings is the global notification setting
func (*NotifySettings) NormalizeRetry ¶
func (n *NotifySettings) NormalizeRetry(retry Retry) Retry
NormalizeRetry return a normalized retry value
func (*NotifySettings) NormalizeTimeOut ¶
func (n *NotifySettings) NormalizeTimeOut(t time.Duration) time.Duration
NormalizeTimeOut return a normalized timeout value
type ProbeSettings ¶
type ProbeSettings struct { Interval time.Duration Timeout time.Duration StatusChangeThresholdSettings NotificationStrategySettings }
ProbeSettings is the global probe setting
func (*ProbeSettings) NormalizeInterval ¶
func (p *ProbeSettings) NormalizeInterval(t time.Duration) time.Duration
NormalizeInterval return a normalized time interval value
func (*ProbeSettings) NormalizeNotificationStrategy ¶
func (p *ProbeSettings) NormalizeNotificationStrategy(t NotificationStrategySettings) NotificationStrategySettings
NormalizeNotificationStrategy return a normalized notification strategy value
func (*ProbeSettings) NormalizeThreshold ¶
func (p *ProbeSettings) NormalizeThreshold(t StatusChangeThresholdSettings) StatusChangeThresholdSettings
NormalizeThreshold return a normalized threshold value
func (*ProbeSettings) NormalizeTimeOut ¶
func (p *ProbeSettings) NormalizeTimeOut(t time.Duration) time.Duration
NormalizeTimeOut return a normalized timeout value
type Retry ¶
type Retry struct { Times int `yaml:"times" json:"times,omitempty" jsonschema:"title=Retry Times,description=how many times need to retry,minimum=1"` Interval time.Duration `` /* 147-byte string literal not displayed */ }
Retry is the settings of retry
type StatusChangeThresholdSettings ¶
type StatusChangeThresholdSettings struct { // the failures threshold such as 2, 5 Failure int `` /* 162-byte string literal not displayed */ // the success threshold such as 2, 5 Success int `` /* 161-byte string literal not displayed */ }
StatusChangeThresholdSettings is the settings for probe threshold
type TLS ¶
type TLS struct { CA string `yaml:"ca" json:"ca,omitempty" jsonschema:"title=CA File,description=the CA file path"` Cert string `yaml:"cert" json:"cert,omitempty" jsonschema:"title=Cert File,description=the Cert file path"` Key string `yaml:"key" json:"key,omitempty" jsonschema:"title=Key File,description=the Key file path"` Insecure bool `yaml:"insecure" json:"insecure,omitempty" jsonschema:"title=Insecure,description=whether to skip the TLS verification"` }
TLS is the configuration for TLS files