health

package
v0.0.0-...-6eef5cf Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2014 License: Apache-2.0 Imports: 5 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

This section is empty.

Types

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.

type HTTPHealthChecker

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

HTTPHealthChecker is an implementation of HealthChecker which checks container health by sending HTTP Get requests.

func (*HTTPHealthChecker) HealthCheck

func (h *HTTPHealthChecker) HealthCheck(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(container api.Container) (Status, error)
}

HealthChecker defines an abstract interface for checking container health.

func NewHealthChecker

func NewHealthChecker() HealthChecker

NewHealthChecker creates a new HealthChecker which supports multiple types of liveness probes.

type MuxHealthChecker

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

MuxHealthChecker bundles multiple implementations of HealthChecker of different types.

func (*MuxHealthChecker) HealthCheck

func (m *MuxHealthChecker) HealthCheck(container api.Container) (Status, error)

HealthCheck delegates the health-checking of the container to one of the bundled implementations. It chooses an implementation according to container.LivenessProbe.Type. If there is no matching health checker it returns Unknown, nil.

type Status

type Status int
const (
	Healthy Status = iota
	Unhealthy
	Unknown
)

Status takes only one of values of these constants.

func Check

func Check(url string, client HTTPGetInterface) (Status, error)

Check checks if a GET request to the url succeeds. 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.

Jump to

Keyboard shortcuts

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