health

package
v0.0.0-...-e20f597 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2014 License: Apache-2.0 Imports: 9 Imported by: 0

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

func IsExitError(err error) bool

Types

type CommandRunner

type CommandRunner interface {
	RunInContainer(podFullName, containerName string, cmd []string) ([]byte, error)
}

type ExecHealthChecker

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

func (*ExecHealthChecker) HealthCheck

func (e *ExecHealthChecker) HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error)

type HTTPGetInterface

type HTTPGetInterface interface {
	Get(url string) (*http.Response, error)
}

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.

const (
	Healthy Status = iota
	Unhealthy
	Unknown
)

Status values must be one of these constants.

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

func DoTCPCheck(addr string) (Status, error)

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.

type TCPHealthChecker

type TCPHealthChecker struct{}

func (*TCPHealthChecker) HealthCheck

func (t *TCPHealthChecker) HealthCheck(podFullName string, currentState api.PodState, container api.Container) (Status, error)

Jump to

Keyboard shortcuts

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