health

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(options *Options, log logger.LogInfoFormat, checkers []Checker) app.HealthServer

Types

type Checker

type Checker interface {
	Name() string
	Check() Health
}

Checker is a interface used to provide an indication of application 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(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) ServeHTTP

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

ServeHTTP returns a json encoded Health set the status to http.StatusServiceUnavailable if the check is down

type Health

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

func NewHealth

func NewHealth() Health

NewHealth return a new Health with status 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 status 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 Status is Down

func (Health) IsUnknown

func (h Health) IsUnknown() bool

IsUnknown returns true if Status is Unknown

func (Health) IsUp

func (h Health) IsUp() bool

IsUp returns true if Status is Up

func (Health) MarshalJSON

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

MarshalJSON is a custom JSON marshaller

func (*Health) Unknown

func (h *Health) Unknown() *Health

Unknown set the status to Unknown

func (*Health) Up

func (h *Health) Up() *Health

Up set the status to Up

type Options

type Options struct {
	Host         string
	Port         uint16
	ReadTimeout  int64
	WriteTimeout int64
}

func NewOptions

func NewOptions(v *viper.Viper) (*Options, error)

Directories

Path Synopsis
di

Jump to

Keyboard shortcuts

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