health

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: Apache-2.0, BSD-3-Clause, MIT Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const PlatformsIndicatorName = "platforms"

PlatformsIndicatorName is the name of platforms indicator

View Source
const StorageIndicatorName = "storage"

StorageIndicatorName is the name of storage indicator

Variables

View Source
var MinInterval = 10 * time.Second

MinInterval is the minimum check interval for a indicator configuration

Functions

func Configure added in v0.5.0

func Configure(ctx context.Context, indicators []Indicator, settings *Settings) (*h.Health, map[string]int64, error)

Configure creates new health using provided settings.

Types

type Health

type Health struct {
	Status  Status                 `json:"status"`
	Details map[string]interface{} `json:"details,omitempty"`
}

Health contains information about the health of a component.

func New

func New() *Health

New returns a new Health with an unknown status an empty details.

func (*Health) WithDetail

func (h *Health) WithDetail(key string, val interface{}) *Health

WithDetail adds a detail to the health

func (*Health) WithDetails

func (h *Health) WithDetails(details map[string]interface{}) *Health

WithDetails adds the given details to the health

func (*Health) WithError

func (h *Health) WithError(err error) *Health

WithError sets the status of the health to DOWN and adds an error detail

func (*Health) WithStatus

func (h *Health) WithStatus(status Status) *Health

WithStatus sets the status of the health

type Indicator

type Indicator interface {
	// Name returns the name of the component
	Name() string

	// Status returns the health information of the component
	Status() (interface{}, error)
}

Indicator is an interface to provide the health of a component

type IndicatorSettings added in v0.5.0

type IndicatorSettings struct {
	Fatal             bool          `mapstructure:"fatal" description:"if the indicator affects the overall status, if false not failures_threshold expected"`
	FailuresThreshold int64         `mapstructure:"failures_threshold" description:"number of failures in a row that will affect overall status"`
	Interval          time.Duration `mapstructure:"interval" description:"time between health checks of components"`
}

IndicatorSettings type to be loaded from the environment

func DefaultIndicatorSettings added in v0.5.0

func DefaultIndicatorSettings() *IndicatorSettings

DefaultIndicatorSettings returns default values for indicator settings

func (*IndicatorSettings) Validate added in v0.5.0

func (is *IndicatorSettings) Validate() error

Validate validates indicator settings

type Registry

type Registry struct {
	// HealthIndicators are the currently registered health indicators
	HealthIndicators []Indicator
}

Registry is a struct to store health indicators

func NewDefaultRegistry

func NewDefaultRegistry() *Registry

NewDefaultRegistry returns a default empty health registry

func (*Registry) SetIndicator added in v0.6.0

func (r *Registry) SetIndicator(healthIndicator Indicator)

SetIndicator adds or replaces existing indicator with same name in registry

type Settings added in v0.5.0

type Settings struct {
	Indicators map[string]*IndicatorSettings `mapstructure:"indicators"`
}

Settings type to be loaded from the environment

func DefaultSettings added in v0.5.0

func DefaultSettings() *Settings

DefaultSettings returns default values for health settings

func (*Settings) Validate added in v0.5.0

func (s *Settings) Validate() error

Validate validates health settings

type Status

type Status string

Status represents the overall health status of a component

const (
	// StatusUp indicates that the checked component is up and running
	StatusUp Status = "UP"
	// StatusDown indicates the the checked component has an issue and is unavailable
	StatusDown Status = "DOWN"
	// StatusUnknown indicates that the health of the checked component cannot be determined
	StatusUnknown Status = "UNKNOWN"
)

type StatusListener added in v0.5.0

type StatusListener struct{}

func (*StatusListener) HealthCheckFailed added in v0.5.0

func (sl *StatusListener) HealthCheckFailed(state *health.State)

func (*StatusListener) HealthCheckRecovered added in v0.5.0

func (sl *StatusListener) HealthCheckRecovered(state *health.State, numberOfFailures int64, unavailableDuration float64)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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