health

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UP             status = "UP"
	DOWN                  = "DOWN"
	OUT_OF_SERVICE        = "OUT OF SERVICE"
	UNKNOWN               = "UNKNOWN"
)

Variables

This section is empty.

Functions

func TelnetCheck

func TelnetCheck(prefix string, checkedUrl string, health *Health)

Types

type Checker

type Checker interface {
	Check() Health
}

Checker is a interface used to provide an indication of application health.

type CheckerFunc

type CheckerFunc func() Health

CheckerFunc is an adapter to allow the use of ordinary go functions as Checkers.

func (CheckerFunc) Check

func (f CheckerFunc) Check() Health

type CompositeChecker

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

CompositeChecker aggregate a list of Checkers

func NewCompositeChecker

func NewCompositeChecker() CompositeChecker

NewCompositeChecker creates a new CompositeChecker

func (*CompositeChecker) AddChecker

func (c *CompositeChecker) AddChecker(name string, checker Checker)

AddChecker add a Checker to the aggregator

func (*CompositeChecker) AddInfo

func (c *CompositeChecker) AddInfo(key string, value interface{}) *CompositeChecker

AddInfo adds a Info value to the Info map

func (CompositeChecker) Check

func (c CompositeChecker) Check() Health

Check returns the combination of all checkers added if some check is not UP, the combined is marked as DOWN

type Handler

type Handler struct {
	CompositeChecker
}

Handler is a HTTP Server Handler implementation

func NewHandler

func NewHandler() Handler

NewHandler returns a new Handler

func (Handler) GinHandler

func (h Handler) GinHandler(ctx *gin.Context)

ServeHTTP returns a json encoded Health set the State to http.StatusServiceUnavailable if the check is DOWN

func (Handler) ServeHTTP

func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP returns a json encoded Health set the State to http.StatusServiceUnavailable if the check is DOWN

type Health

type Health struct {
	Status status
	Info   map[string]interface{}
}

Health is a health State struct

func NewHealth

func NewHealth() Health

NewHealth return a new Health with State Down

func (*Health) AddInfo

func (h *Health) AddInfo(key string, value interface{}) *Health

AddInfo adds a Info value to the Info map

func (*Health) Down

func (h *Health) Down() *Health

Down set the State to Down

func (Health) GetInfo

func (h Health) GetInfo(key string) interface{}

GetInfo returns a value from the Info map

func (Health) IsDown

func (h Health) IsDown() bool

IsDown returns true if State is Down

func (Health) IsOutOfService

func (h Health) IsOutOfService() bool

IsOutOfService returns true if State is IsOutOfService

func (Health) IsUnknown

func (h Health) IsUnknown() bool

IsUnknown returns true if State is Unknown

func (Health) IsUp

func (h Health) IsUp() bool

IsUp returns true if State is Up

func (Health) MarshalJSON

func (h Health) MarshalJSON() ([]byte, error)

MarshalJSON is a custom JSON marshaller

func (*Health) OutOfService

func (h *Health) OutOfService() *Health

OutOfService set the State to OutOfService

func (*Health) Unknown

func (h *Health) Unknown() *Health

Unknown set the State to Unknown

func (*Health) Up

func (h *Health) Up() *Health

Up set the State to Up

type HealthFunc

type HealthFunc func() Health

Jump to

Keyboard shortcuts

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