health

package
v0.0.0-...-2ea7981 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// The HTTP status that we use for 'ready' or 'live', with detail content.  (Kubernetes
	// interprets any 200<=status<400 as 'good'.)
	StatusGood = 200

	// The HTTP status that we use for 'ready' or 'live', without any detail content.  204 means
	// "No Content: The server successfully processed the request and is not returning any
	// content."  (Kubernetes interprets any 200<=status<400 as 'good'.)
	StatusGoodNoContent = 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 interprets any
	// status>=400 as 'bad'.)
	StatusBad = 503
)

Variables

This section is empty.

Functions

func GlobalOverride

func GlobalOverride(name string) *time.Duration

func SetGlobalTimeoutOverrides

func SetGlobalTimeoutOverrides(overrides map[string]time.Duration)

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
	Detail string
}

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

func (*HealthReport) String

func (h *HealthReport) String() string

Jump to

Keyboard shortcuts

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