health

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParam    = errors.New("invalid param")
	StatusError = health.Status("error")
)

Functions

This section is empty.

Types

type CheckType

type CheckType struct {
	Title  string  `json:"title"`
	Type   string  `json:"type"`
	Desc   string  `json:"desc"`
	Params []Param `json:"params"`
}

type Checker

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

func (*Checker) Run

func (c *Checker) Run()

type Controller

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

func NewController

func NewController() *Controller

func (*Controller) RegisterRoute

func (c *Controller) RegisterRoute(group *gin.RouterGroup)

type Count

type Count struct {
	Total   int64 `json:"total"`
	Up      int64 `json:"up"`
	Down    int64 `json:"down"`
	Unknown int64 `json:"unknown"`
	Error   int64 `json:"error"`
}

type Health

type Health struct {
	ID      uuid.UUID `json:"id" gorm:"type:uuid;primaryKey" swaggerignore:"true" example:"00000000-0000-0000-0000-000000000000"`
	Title   string    `json:"title" gorm:"not null" validate:"required"`
	Desc    string    `json:"desc"`
	Type    string    `json:"type" gorm:"length:32" validate:"oneof=ping ssh http database"`
	Enabled bool      `json:"enabled"`
	Params  string    `json:"params" validate:"required"`
	Status  string    `json:"status"` // last result
	RTT     int64     `json:"rtt"`    // last result

	database.BaseModel
}

func (*Health) BeforeCreate

func (h *Health) BeforeCreate(tx *gorm.DB) error

func (*Health) TableName

func (h *Health) TableName() string

type HealthListResponse

type HealthListResponse struct {
	ID      uuid.UUID `json:"id" gorm:"type:uuid;primaryKey" swaggerignore:"true" example:"00000000-0000-0000-0000-000000000000"`
	Title   string    `json:"title" gorm:"not null" validate:"required"`
	Desc    string    `json:"desc"`
	Type    string    `json:"type" gorm:"length:32" validate:"oneof=ping ssh http database"`
	Enabled bool      `json:"enabled"`
	Status  string    `json:"status"` // last result
	RTT     int64     `json:"rtt"`    // last result
}

type Param

type Param struct {
	Key      string `json:"key"`
	Value    any    `json:"value"`
	Title    string `json:"title"`
	Type     string `json:"type"`
	Required bool   `json:"required"`
	Desc     string `json:"desc"`
}

type Params

type Params []Param

func (*Params) GetKey

func (ps *Params) GetKey(key string) any

type Record

type Record struct {
	ID       uuid.UUID `json:"id" gorm:"type:uuid;primaryKey" swaggerignore:"true" example:"00000000-0000-0000-0000-000000000000"`
	ParentId uuid.UUID `json:"parentId" gorm:"type:uuid;" swaggerignore:"true" example:"00000000-0000-0000-0000-000000000000"`

	Status string `json:"status"`
	Rtt    int64  `json:"rtt"`
	Result string `json:"result"` // json string

	database.BaseModel
}

func (*Record) BeforeCreate

func (h *Record) BeforeCreate(tx *gorm.DB) error

func (*Record) TableName

func (h *Record) TableName() string

type Service

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

func GetService

func GetService() *Service

func (*Service) AddHealth

func (s *Service) AddHealth(health *Health) error

func (*Service) DeleteHealth

func (s *Service) DeleteHealth(health *Health) error

func (*Service) DetailHealth

func (s *Service) DetailHealth(id uuid.UUID) (*Health, error)

func (*Service) GetHealthCheckTypes

func (s *Service) GetHealthCheckTypes() []CheckType

func (*Service) GetTimeRangeRecord

func (s *Service) GetTimeRangeRecord(healthId uuid.UUID, startTime time.Time, endTime time.Time) ([]*Record, error)

func (*Service) HealthStatistics

func (s *Service) HealthStatistics() (*Statistics, error)

func (*Service) Initialize

func (s *Service) Initialize() error

func (*Service) ListHealth

func (s *Service) ListHealth(health *Health) ([]*HealthListResponse, error)

func (*Service) UpdateHealth

func (s *Service) UpdateHealth(health *Health) error

type Statistics

type Statistics struct {
	Total     int64                 `json:"total"`
	Up        int64                 `json:"up"`
	Down      int64                 `json:"down"`
	Unknown   int64                 `json:"unknown"`
	Error     int64                 `json:"error"`
	Ping      int64                 `json:"ping"`
	SSH       int64                 `json:"ssh"`
	HTTP      int64                 `json:"http"`
	Database  int64                 `json:"database"`
	ErrorList []*HealthListResponse `json:"errorList"`
	SlowList  []*HealthListResponse `json:"slowList"` // rtt > 460
}

Jump to

Keyboard shortcuts

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