health

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 8 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() *url.URL
	Config() *HealthCheckConfig
	UpdateURL(url *url.URL)
}

type HealthMonCheck added in v0.11.0

type HealthMonCheck interface {
	HealthMonitor
	HealthChecker
}

type JSONRepresentation added in v0.11.0

type JSONRepresentation struct {
	Name     string
	Config   *HealthCheckConfig
	Status   Status
	Started  time.Time
	Uptime   time.Duration
	Latency  time.Duration
	LastSeen time.Time
	Detail   string
	URL      *url.URL
	Extra    map[string]any
}

func (*JSONRepresentation) MarshalJSON added in v0.11.1

func (jsonRepr *JSONRepresentation) MarshalJSON() ([]byte, error)

type Status

type Status uint8

func NewStatus added in v0.11.0

func NewStatus(s string) Status

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