healthcheck

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHealthHandler

func GetHealthHandler(checkers ...Checker) http.HandlerFunc

Types

type Check

type Check struct {
	Key               Key               `json:"-"`
	ComponentId       string            `json:",omitempty"`
	ComponentType     string            `json:",omitempty"`
	ObservedValue     interface{}       `json:",omitempty"`
	ObservedUnit      string            `json:",omitempty"`
	Status            Status            `json:",omitempty"`
	AffectedEndpoints []string          `json:",omitempty"`
	Time              time.Time         `json:",omitempty"`
	Output            string            `json:",omitempty"`
	Links             map[string]string `json:",omitempty"`
}

Check is an individual element of the array returned for a given Checks key.

See: https://inadarei.github.io/rfc-healthcheck/#the-checks-object

type Checker

type Checker interface {
	Check() ([]Check, Status)
}

type Checks

type Checks map[Key][]Check

func (Checks) AddChecks

func (c Checks) AddChecks(check ...Check)

AddChecks is a convenience method that adds a result for a [] whether or not its key was previously known.

type Health

type Health struct {
	Status      Status
	Version     string
	ReleaseId   string
	Notes       []string
	Output      string
	Checks      Checks
	Links       map[string]string
	ServiceId   string
	Description string
}

type Key

type Key struct {
	ComponentName   string
	MeasurementName string
}

Key provides a composite key denoting the component name and measurement name of a health checks.

See: https://inadarei.github.io/rfc-healthcheck/#the-checks-object

func (Key) MarshalText

func (k Key) MarshalText() ([]byte, error)

func (*Key) Scan

func (k *Key) Scan(state fmt.ScanState, verb rune) error

func (Key) String

func (k Key) String() string

func (*Key) UnmarshalText

func (k *Key) UnmarshalText(text []byte) error

type Status

type Status int

State indicates whether the service as-a-whole and the individual checks are okay.

const (
	Pass Status = iota
	Warn Status = 1
	Fail Status = 2
)

These must be organized from least to greatest severity and must be in the same order as the data structure below. (Replace with go-enumeration when it's available.)

func ParseStatus

func ParseStatus(input string) (Status, error)

func (Status) MarshalText

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

func (Status) Max

func (s Status) Max(other Status) Status

func (Status) Severity

func (s Status) Severity() int

func (Status) StatusCode

func (s Status) StatusCode() int

func (Status) String

func (s Status) String() string

func (*Status) UnmarshalText

func (s *Status) UnmarshalText(json []byte) error

Jump to

Keyboard shortcuts

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