health

package
v1.1.1-beta Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HealthLevelCritical     Level = 0
	HealthLevelHighPriority Level = 100
	HealthLevelLowPriority  Level = 200

	TypeInternal Type = 0
	TypeExternal Type = 100
	TypeExpose   Type = 200

	StatusStopping    StatusCode = -5
	StatusAbnormal    StatusCode = -4
	StatusBadInterval StatusCode = -3
	StatusFatal       StatusCode = -2
	StatusDown        StatusCode = -1
	StatusUnknown     StatusCode = 0
	StatusUp          StatusCode = 1
	StatusOk          StatusCode = 2
	StatusWarning     StatusCode = 3
)

Variables

View Source
var DefaultCheckPlan = CheckerPlan{
	DeepPercent:     float32(0.2),
	DeepInterval:    10 * time.Second,
	ShallowInterval: 10 * time.Second,
	DeepDuration:    0,
	ShallowDuration: 0,
}

Functions

func ReplaceDefault

func ReplaceDefault(manager *HealthManager)

Types

type CheckDesc

type CheckDesc struct {
	Name  string `json:"name"`
	Type  Type   `json:"type"`
	Level Level  `json:"level"`
}

type CheckInfo

type CheckInfo struct {
	Desc   CheckDesc
	Record CheckRecord
}

type CheckOption

type CheckOption struct {
	Deep bool
}

type CheckRecord

type CheckRecord struct {
	Status        Status        `json:"status"`
	CheckTime     time.Time     `json:"check_time"`
	CheckDuration time.Duration `json:"check_duration"`
	CheckDetail   string        `json:"check_detail"`
	SelfUpload    bool          `json:"self_upload"`
}

func (CheckRecord) IsBadStatus

func (record CheckRecord) IsBadStatus() bool

type Checker

type Checker interface {
	Check(ctx context.Context) error
}

type CheckerPlan

type CheckerPlan struct {
	DeepPercent     float32
	DeepInterval    time.Duration
	ShallowInterval time.Duration
	DeepDuration    time.Duration
	ShallowDuration time.Duration
}

type HealthManager

type HealthManager struct {
	// contains filtered or unexported fields
}

func Default

func Default() *HealthManager

func NewManager

func NewManager(opt ManagerOption, logger *zap.Logger) *HealthManager

func (*HealthManager) GetReport

func (manager *HealthManager) GetReport() (Report, error)

func (*HealthManager) IsUp

func (manager *HealthManager) IsUp() bool

func (*HealthManager) UpdateCheckRecord

func (manager *HealthManager) UpdateCheckRecord(name string, record CheckRecord) error

func (*HealthManager) UpdateChecker

func (manager *HealthManager) UpdateChecker(desc CheckDesc, plan CheckerPlan, checker Checker) (*StatusReporter, error)

type Level

type Level int32

func (Level) String

func (level Level) String() string

type ManagerOption

type ManagerOption struct {
	DefaultPlan CheckerPlan
}

type Report

type Report struct {
	BadCritical   int32
	BadHeighLevel int32
	BadLowLevel   int32
	Internal      []CheckInfo
	External      []CheckInfo
	Expose        []CheckInfo
}

type Status

type Status []StatusCode

func (Status) IsUp

func (ss Status) IsUp() bool

type StatusCode

type StatusCode int32

func (StatusCode) String

func (sc StatusCode) String() string

type StatusReporter

type StatusReporter struct {
	// contains filtered or unexported fields
}

func (*StatusReporter) ReportStatus

func (reporter *StatusReporter) ReportStatus(detail string, status ...StatusCode)

type Type

type Type int32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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