health

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 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
)

Variables

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"`
}

type HealthCheckResult

type HealthCheckResult struct {
	Healthy bool
	Detail  string
	Latency time.Duration
}

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) MarshalJSON

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

func (Status) String

func (s Status) String() string

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