health

package
v3.6.0-0.dev+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: Apache-2.0 Imports: 5 Imported by: 175

Documentation

Index

Constants

View Source
const (
	// The HTTP status that we use for 'ready' or 'live'.  204 means "No Content: The server
	// successfully processed the request and is not returning any content."  (Kubernetes
	// interpets any 200<=status<400 as 'good'.)
	StatusGood = 204

	// The HTTP status that we use for 'not ready' or 'not live'.  503 means "Service
	// Unavailable: The server is currently unavailable (because it is overloaded or down for
	// maintenance). Generally, this is a temporary state."  (Kubernetes interpets any
	// status>=400 as 'bad'.)
	StatusBad = 503
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthAggregator

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

A HealthAggregator receives health reports from individual reporters (which are typically components of a particular daemon or application) and aggregates them into an overall health summary. For each monitored kind of health, all of the reporters that report that need to say that it is good; for example, to be 'ready' overall, all of the reporters that report readiness need to have recently said 'Ready: true'.

func NewHealthAggregator

func NewHealthAggregator() *HealthAggregator

func (*HealthAggregator) RegisterReporter

func (aggregator *HealthAggregator) RegisterReporter(name string, reports *HealthReport, timeout time.Duration)

RegisterReporter registers a reporter with a HealthAggregator. The aggregator uses NAME to identify the reporter. REPORTS indicates the kinds of health that this reporter will report. TIMEOUT is the expiry time for this reporter's reports; the implication of which is that the reporter should normally refresh its reports well before this time has expired.

func (*HealthAggregator) Report

func (aggregator *HealthAggregator) Report(name string, report *HealthReport)

Report reports current health from a reporter to a HealthAggregator. NAME is the reporter's name and REPORTS conveys the current status, for each kind of health that the reporter said it was going to report when it called RegisterReporter.

func (*HealthAggregator) ServeHTTP

func (aggregator *HealthAggregator) ServeHTTP(enabled bool, host string, port int)

ServeHTTP publishes the current overall liveness and readiness at http://HOST:PORT/liveness and http://HOST:PORT/readiness respectively. A GET request on those URLs returns StatusGood or StatusBad, according to the current overall liveness or readiness. These endpoints are designed for use by Kubernetes liveness and readiness probes.

func (*HealthAggregator) Summary

func (aggregator *HealthAggregator) Summary() *HealthReport

Summary calculates the current overall health for a HealthAggregator.

type HealthReport

type HealthReport struct {
	Live  bool
	Ready bool
}

The HealthReport struct has slots for the levels of health that we monitor and aggregate.

Jump to

Keyboard shortcuts

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