health

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2019 License: Apache-2.0, BSD-3-Clause, MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregationPolicy

type AggregationPolicy interface {
	// Apply processes the given healths to build a single health
	Apply(healths map[string]*Health) *Health
}

AggregationPolicy is an interface to provide aggregated health information

type DefaultAggregationPolicy

type DefaultAggregationPolicy struct {
}

DefaultAggregationPolicy aggregates the healths by constructing a new Health based on the given where the overall health status is negative if one of the healths is negative and positive if all are positive

func (*DefaultAggregationPolicy) Apply

func (*DefaultAggregationPolicy) Apply(healths map[string]*Health) *Health

Apply aggregates the given healths

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

func (h *Health) Down() *Health

Down sets the health status to down

func (*Health) Unknown

func (h *Health) Unknown() *Health

Unknown sets the health status to unknown

func (*Health) Up

func (h *Health) Up() *Health

Up sets the health status to up

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
	// Health returns the health of the component
	Health() *Health
}

Indicator is an interface to provide the health of a component

type Registry

type Registry interface {
	// AddHealthIndicators registers a new health indicator
	AddHealthIndicator(indicator Indicator)
	// HealthIndicators returns the currently registered health indicators
	HealthIndicators() []Indicator

	// RegisterHealthAggregationPolicy sets the health aggregationPolicy
	RegisterHealthAggregationPolicy(aggregator AggregationPolicy)
	// HealthAggregationPolicy returns the registered health aggregationPolicy
	HealthAggregationPolicy() AggregationPolicy
}

Registry is an interface to store and fetch health indicators

func NewDefaultRegistry

func NewDefaultRegistry() Registry

NewDefaultRegistry returns a default health registry with a single ping indicator and a default aggregation policy

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

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