conf

package
v0.0.0-...-4389a61 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IPV4 = IPProtocol("ip4")
	IPV6 = IPProtocol("ip6")
)
View Source
var IPProtocol2Gauge = map[IPProtocol]float64{
	IPV4: 4,
	IPV6: 6,
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Modules map[string]Module `mapstructure:"modules"`
}

type HTTPProbe

type HTTPProbe struct {
	ValidStatusCode              []int                   `mapstructure:"valid_status_code"`             // Verify response code
	ValidHTTPVersions            []string                `mapstructure:"valid_status_code"`             // Adapt to HTTP1.x/HTTP2
	IPProtocol                   IPProtocol              `mapstructure:"preferred_ip_protocol"`         // Adapt to IPV4/IPV6
	IPProtocolFallback           bool                    `mapstructure:"ip_protocol_fallback"`          // 允许IPV6协议降级
	SkipResolvePhaseWithProxy    bool                    `mapstructure:"skip_resolve_phase_with_proxy"` // 解析域名时不使用代理
	NoFollowRedirects            *bool                   `mapstructure:"no_follow_redirects"`           // 禁止重定向
	FailIfSSL                    bool                    `mapstructure:"fail_if_ssl"`                   // 如果被监控项为HTTPS,则失败
	FailIfNotSSL                 bool                    `mapstructure:"fail_if_not_ssl"`               // 如果被监控项不是HTTPS,则失败
	Method                       string                  `mapstructure:"method"`
	Headers                      map[string]string       `mapstructure:"headers"`                     // Request Headers
	FailIfBodyMatchesRegexp      []Regexp                `mapstructure:"fail_if_body_matches_regexp"` // if Response Headers not include origin strings, return failed  Regexp是对regex.Regexp的封装,包含了源正则字符串
	FailIfBodyNotMatchesRegexp   []Regexp                `mapstructure:"fail_if_body_not_matches_regexp"`
	FailIfHeaderMatchesRegexp    []HeaderMatch           `mapstructure:"fail_if_header_matches"`
	FailIfHeaderNotMatchesRegexp []HeaderMatch           `mapstructure:"fail_if_header_not_matches"`
	Body                         string                  `mapstructure:"body,omitempty"`
	Compression                  string                  `mapstructure:"compression"`        // 指定压缩算法 e.g. gzip
	BodySizeLimit                units.Base2Bytes        `mapstructure:"body_size_limit"`    // units是一个单位转换工作 e.g. 1Mi => 1024*1024
	HTTPClientConfig             config.HTTPClientConfig `mapstructure:"http_client_config"` // prometheus 官方的工具包,包括了BearToken、BasicAuth、TLS、SSL等协议的认证,主要作用是配置http request
}

func NewDefaultHTTPProbe

func NewDefaultHTTPProbe() *HTTPProbe

func (*HTTPProbe) ChooseProtocol

func (h *HTTPProbe) ChooseProtocol(ctx context.Context, target string) (ip *net.IPAddr, lookupTime float64, err error)

ChooseProtocol 确定给定的target域名/ip对应的ip protocol

func (HTTPProbe) LookUpWithoutProxy

func (h HTTPProbe) LookUpWithoutProxy(ctx context.Context, target string, durationGaugeVec *prometheus.GaugeVec) (ip *net.IPAddr, err error)

type HeaderMatch

type HeaderMatch struct {
	Header       string `mapstructure:"header"`
	Regexp       Regexp `mapstructure:"regexp"`
	AllowMissing bool   `mapstructure:"allow_missing"` // 是否允许不含value
}

type IPProtocol

type IPProtocol string

type Module

type Module struct {
	Prober  string        `mapstructure:"prober" validate:"required"`
	Timeout time.Duration `mapstructure:"timeout"`
	HTTP    *HTTPProbe    `mapstructure:"http"`
}

func NewDefaultModule

func NewDefaultModule() *Module

type Regexp

type Regexp struct {
	*regexp.Regexp
	// contains filtered or unexported fields
}

func MustNewRegexp

func MustNewRegexp(regexExpr string) *Regexp

MustNewRegexp works like NewRegexp, but panics if the regular expression does not compile.

func NewRegexp

func NewRegexp(regexExpr string) (*Regexp, error)

type SafeConfig

type SafeConfig struct {
	sync.RWMutex
	C *Config
}

SafeConfig Adjust multi threads condition

func C

func C() *SafeConfig

C 保护私有变量

func (*SafeConfig) ReloadConfig

func (sc *SafeConfig) ReloadConfig(configFile string) (err error)

Jump to

Keyboard shortcuts

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