health

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	// Check 检查应用健康情况
	Check(ctx context.Context) Health
}

Checker 应用检查器接口

type Health

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

Health 健康状态

func NewHealth

func NewHealth() Health

NewHealth 新建健康状态,默认状态为 Unknown

func (*Health) AddInfo

func (h *Health) AddInfo(key string, value any) *Health

AddInfo 添加健康键值信息

func (*Health) Down

func (h *Health) Down() *Health

Down 设置健康状态为 Down

func (Health) GetInfo

func (h Health) GetInfo(key string) any

GetInfo 获取健康键值信息

func (Health) GetStatus

func (h Health) GetStatus() Status

GetStatus 获取健康状态信息

func (Health) IsDown

func (h Health) IsDown() bool

IsDown 判断是否为 Down 状态

func (Health) IsOutOfService

func (h Health) IsOutOfService() bool

IsOutOfService 判断是否为 IsOutOfService 状态

func (Health) IsUnknown

func (h Health) IsUnknown() bool

IsUnknown 判断是否为 Unknown 状态

func (Health) IsUp

func (h Health) IsUp() bool

IsUp 判断是否为 Up 状态

func (Health) MarshalJSON

func (h Health) MarshalJSON() ([]byte, error)

MarshalJSON 实现 json.Marshaler 接口的 MarshalJSON 方法

func (*Health) OutOfService

func (h *Health) OutOfService() *Health

OutOfService 设置健康状态为 OutOfService

func (*Health) Unknown

func (h *Health) Unknown() *Health

Unknown 设置健康状态为 Unknown

func (*Health) UnmarshalJSON

func (h *Health) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现 json.Unmarshaler 接口的 UnmarshalJSON 方法

func (*Health) Up

func (h *Health) Up() *Health

Up 设置健康状态为 Up

type Status

type Status int32

Status 健康状态

const (
	// Up 健康状态:UP
	Up Status = 0 // UP
	// Down 健康状态:DOWN
	Down Status = 1 // DOWN
	// OutOfService 健康状态:OUT OF SERVICE
	OutOfService Status = 2 // OUT OF SERVICE
	// Unknown 健康状态:UNKNOWN
	Unknown Status = 3 // UNKNOWN
)

func StatusString

func StatusString(s string) (Status, error)

StatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func StatusValues

func StatusValues() []Status

StatusValues returns all values of the enum

func (Status) IsAStatus

func (i Status) IsAStatus() bool

IsAStatus returns "true" if the value is listed in the enum definition. "false" otherwise

func (Status) MarshalJSON

func (i Status) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Status

func (Status) String

func (i Status) String() string

func (*Status) UnmarshalJSON

func (i *Status) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Status

Directories

Path Synopsis
checker

Jump to

Keyboard shortcuts

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