global

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package global is the package for EaseProbe

Index

Constants

View Source
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"
)
View Source
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
)
View Source
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"
)
View Source
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

View Source
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 added in v1.6.0

func CommandLine(cmd string, args []string) string

CommandLine will return the whole command line which includes command and all arguments

func DoRetry added in v1.1.0

func DoRetry(kind, name, tag string, r Retry, fn func() error) error

DoRetry is a help function to retry the function if it returns error

func EnumMarshalJSON added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 added in v1.8.0

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 FooterString added in v1.5.0

func FooterString() string

FooterString return the footer string e.g. "EaseProbe v1.0.0 @ localhost"

func GetTimeFormat added in v1.7.0

func GetTimeFormat() string

GetTimeFormat return the time format

func GetTimeLocation added in v1.7.0

func GetTimeLocation() *time.Location

GetTimeLocation return the time zone

func GetWorkDir added in v1.5.0

func GetWorkDir() string

GetWorkDir return the current working directory

func InitEaseProbe added in v1.5.0

func InitEaseProbe(name, icon string)

InitEaseProbe the EaseProbe

func InitEaseProbeWithTime added in v1.7.0

func InitEaseProbeWithTime(name, icon, tf, tz string)

InitEaseProbeWithTime init the EaseProbe with time

func MakeDirectory added in v1.5.0

func MakeDirectory(filename string) string

MakeDirectory return the writeable filename

func ReverseMap added in v1.6.0

func ReverseMap[K comparable, V comparable](m map[K]V) map[V]K

ReverseMap just reverse the map from [key, value] to [value, key]

func SetTimeFormat added in v1.7.0

func SetTimeFormat(tf string)

SetTimeFormat set the time format

func SetTimeZone added in v1.7.0

func SetTimeZone(tz string)

SetTimeZone set the time zone

Types

type EaseProbe added in v1.5.0

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

func GetEaseProbe added in v1.5.0

func GetEaseProbe() *EaseProbe

GetEaseProbe return the EaseProbe

type ErrNoRetry added in v1.8.0

type ErrNoRetry struct {
	Message string
}

ErrNoRetry is the error need not retry

func (*ErrNoRetry) Error added in v1.8.0

func (e *ErrNoRetry) Error() string

type NotifySettings

type NotifySettings struct {
	TimeFormat string
	Timeout    time.Duration
	Retry      Retry
}

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 added in v1.1.0

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
}

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) NormalizeThreshold added in v1.9.0

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 added in v1.9.0

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

func (*TLS) Config

func (t *TLS) Config() (*tls.Config, error)

Config return a tls.Config object

Jump to

Keyboard shortcuts

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