Documentation ¶
Overview ¶
Package health contains utilities for health checking, as well as health status information.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHealthChecker ¶
func AddHealthChecker(key string, checker HealthChecker)
Add a health checker to the list of known HealthChecker objects. Any subsequent call to NewHealthChecker will know about this HealthChecker. panics if 'key' is already present.
func IsExitError ¶
Types ¶
type CommandRunner ¶
type ExecHealthChecker ¶
type ExecHealthChecker struct {
// contains filtered or unexported fields
}
func (*ExecHealthChecker) HealthCheck ¶
type HTTPGetInterface ¶
HTTPGetInterface is an abstract interface for testability. It abstracts the interface of http.Client.Get. This is exported because some other packages may want to do direct HTTP checks.
type HTTPHealthChecker ¶
type HTTPHealthChecker struct {
// contains filtered or unexported fields
}
DoHTTPCheck checks if a GET request to the url succeeds. HTTPHealthChecker is an implementation of HealthChecker which checks container health by sending HTTP Get requests.
func (*HTTPHealthChecker) HealthCheck ¶
func (h *HTTPHealthChecker) HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error)
HealthCheck checks if the container is healthy by trying sending HTTP Get requests to the container.
type HealthChecker ¶
type HealthChecker interface {
HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error)
}
HealthChecker defines an abstract interface for checking container health.
func NewExecHealthChecker ¶
func NewExecHealthChecker(runner CommandRunner) HealthChecker
func NewHTTPHealthChecker ¶
func NewHTTPHealthChecker(client *http.Client) HealthChecker
func NewHealthChecker ¶
func NewHealthChecker() HealthChecker
NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes.
type Status ¶
type Status int
Status represents the result of a single health-check operation.
func DoHTTPCheck ¶
func DoHTTPCheck(url string, client HTTPGetInterface) (Status, error)
If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Healthy. If the HTTP response code is unsuccessful, it returns Unhealthy. It returns Unknown and err if the HTTP communication itself fails. This is exported because some other packages may want to do direct HTTP checks.
func DoTCPCheck ¶
DoTCPCheck checks that a TCP socket to the address can be opened. If the socket can be opened, it returns Healthy. If the socket fails to open, it returns Unhealthy. This is exported because some other packages may want to do direct TCP checks.