Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertConfig ¶
type AlertConfig struct { Type AlertType `yaml:"type" json:"type"` SilentPeriod string `yaml:"silent_period" json:"silent_period"` AdanosAddr string `yaml:"adanos_addr" json:"adanos_addr"` AdanosToken string `yaml:"adanos_token" json:"adanos_token"` HTTPAddr string `yaml:"http_addr" json:"http_addr"` HTTPHeaders []HTTPHeader `yaml:"http_header" json:"http_header"` Timeout int64 `yaml:"timeout" json:"timeout"` }
AlertConfig 告警配置
type CheckTypeHTTP ¶
type CheckTypeHTTP struct { Method string `yaml:"method" json:"method,omitempty"` URL string `yaml:"url" json:"url,omitempty"` Headers []HTTPHeader `yaml:"headers" json:"-"` Body string `yaml:"body" json:"body,omitempty"` Timeout int64 `yaml:"timeout" json:"timeout,omitempty"` SuccessRule string `yaml:"success_rule" json:"success_rule,omitempty"` }
CheckTypeHTTP HTTP 类型的心跳检测
func (CheckTypeHTTP) Check ¶
func (cth CheckTypeHTTP) Check(ctx context.Context, hb Healthcheck) error
Check 执行心跳检测
type CheckTypeICMP ¶
type CheckTypeICMP struct { Host string `yaml:"host" json:"host,omitempty"` Count int64 `yaml:"count" json:"count,omitempty"` Timeout int64 `yaml:"timeout" json:"timeout,omitempty"` SuccessRule string `yaml:"success_rule" json:"success_rule,omitempty"` }
CheckTypeICMP ICMP Ping 类型的心跳检测
func (CheckTypeICMP) Check ¶
func (cth CheckTypeICMP) Check(ctx context.Context, hb Healthcheck) error
Check 执行心跳检测
type ConsulService ¶
type ConsulService struct { Tags []string *api.CatalogService pattern.Helpers }
type Discovery ¶
type Discovery struct { Type DiscoveryType `yaml:"type" json:"type,omitempty"` ConsulScheme string `yaml:"consul_scheme" json:"consul_scheme,omitempty"` ConsulAddr string `yaml:"consul_addr" json:"consul_addr,omitempty"` ConsulToken string `yaml:"consul_token" json:"-"` ConsulDC string `yaml:"consul_dc" json:"consul_dc,omitempty"` Filter string `yaml:"filter" json:"filter,omitempty"` Template Healthcheck `yaml:"template" json:"template,omitempty"` }
Discovery 服务发现
func (Discovery) LoadHealthchecks ¶
func (dis Discovery) LoadHealthchecks(ctx context.Context, conf *GlobalConfig) ([]Healthcheck, error)
type DiscoveryType ¶
type DiscoveryType string
DiscoveryType 服务发现类型
const ( // DiscoveryTypeConsul 基于 Consul 的服务发现 DiscoveryTypeConsul DiscoveryType = "consul" )
type Event ¶
type Event struct { Healthcheck Healthcheck `json:"healthcheck"` // LastAliveTime 最后一次该心跳检测活跃的时间,该字段用于检测一个 Alert 是否已经失效了 LastAliveTime time.Time `json:"last_alive_time"` // lastAlertTime 最后一次告警时间 LastAlertTime time.Time `json:"last_alert_time"` // alertTimes 告警次数,从最后一次心跳丢失开始 AlertTimes int64 `json:"alert_times"` LastFailure string `json:"last_failure"` LastSuccessTime time.Time `json:"last_success_time"` }
type GlobalConfig ¶
type GlobalConfig struct { Version string `yaml:"version" json:"version"` Healthchecks []Healthcheck `yaml:"healthchecks" json:"healthchecks"` Discoveries []Discovery `yaml:"discoveries" json:"discoveries"` WorkerNum int `yaml:"worker_num" json:"worker_num"` CheckInterval int64 `yaml:"check_interval" json:"check_interval"` LossThreshold int64 `yaml:"loss_threshold" json:"loss_threshold"` HTTPTimeout int64 `yaml:"http_timeout" json:"http_timeout"` PINGTimeout int64 `yaml:"ping_timeout" json:"ping_timeout"` Alerts []AlertConfig `yaml:"alerts" json:"alerts"` }
GlobalConfig is a global configuration object
func ParseYamlConfig ¶
func ParseYamlConfig(data []byte) (*GlobalConfig, error)
ParseYamlConfig parse config from yaml
func (*GlobalConfig) ToYAML ¶
func (gc *GlobalConfig) ToYAML() string
ToYAML return GlobalConfig as yaml
type HTTPHeader ¶
type HTTPHeader struct { Key string `yaml:"key" json:"key,omitempty"` Value string `yaml:"value" json:"value,omitempty"` }
HTTPHeader http 请求头
type Healthcheck ¶
type Healthcheck struct { ID string `yaml:"id,omitempty" json:"id,omitempty"` Editable bool `yaml:"-" json:"editable,omitempty"` Name string `yaml:"name" json:"name,omitempty"` Tags []string `yaml:"tags" json:"tags,omitempty"` CheckInterval int64 `yaml:"check_interval" json:"check_interval,omitempty"` LossThreshold int64 `yaml:"loss_threshold" json:"loss_threshold,omitempty"` CheckType CheckType `yaml:"check_type" json:"check_type,omitempty"` HTTP CheckTypeHTTP `yaml:"http" json:"http,omitempty"` PING CheckTypeICMP `yaml:"ping" json:"ping,omitempty"` }
Healthcheck 健康检查对象
func (Healthcheck) Schedulable ¶
func (hb Healthcheck) Schedulable() bool
Schedulable return whether the Healthcheck is schedule
func (Healthcheck) String ¶
func (hb Healthcheck) String() string
String convert health-check to string
Click to show internal directories.
Click to hide internal directories.