health

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusUnknown Status = 0
	StatusHealthy        = (1 << iota)
	StatusNapping
	StatusStarting
	StatusUnhealthy
	StatusError

	NumStatuses int = iota - 1

	HealthyMask = StatusHealthy | StatusNapping | StatusStarting
	IdlingMask  = StatusNapping | StatusStarting
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthCheckConfig

type HealthCheckConfig struct {
	Disable  bool          `json:"disable,omitempty" aliases:"disabled"`
	Path     string        `json:"path,omitempty" validate:"omitempty,uri,startswith=/"`
	UseGet   bool          `json:"use_get,omitempty"`
	Interval time.Duration `json:"interval" validate:"omitempty,min=1s"`
	Timeout  time.Duration `json:"timeout" validate:"omitempty,min=1s"`
}

func DefaultHealthConfig

func DefaultHealthConfig() *HealthCheckConfig

type HealthCheckResult

type HealthCheckResult struct {
	Healthy bool          `json:"healthy"`
	Detail  string        `json:"detail"`
	Latency time.Duration `json:"latency"`
}

type HealthChecker

type HealthChecker interface {
	CheckHealth() (result *HealthCheckResult, err error)
	URL() *types.URL
	Config() *HealthCheckConfig
	UpdateURL(url *types.URL)
}

type Status

type Status uint8

func (Status) Bad

func (s Status) Bad() bool

func (Status) Good

func (s Status) Good() bool

func (Status) Idling added in v0.10.0

func (s Status) Idling() bool

func (Status) MarshalJSON

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

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalJSON added in v0.10.0

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

type WithHealthInfo

type WithHealthInfo interface {
	Status() Status
	Uptime() time.Duration
	Latency() time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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