healthz

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: MIT Imports: 3 Imported by: 1

README

Healthz

Build Status

Tools for checking service health.

Documentation

Development

You need Glide to install dependencies.

$ make install

Run tests:

$ make test

License

The MIT License (MIT). Please see License File for more information.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHealthCheckFailed = errors.New("Health check failed")

ErrHealthCheckFailed is a generic error returned when a check fails

Functions

func NewHealthService

func NewHealthService(livenessProbe *Probe, readinessProbe *Probe) http.Handler

NewHealthService creates a new HealthService from user configured Probes

Types

type HealthChecker

type HealthChecker interface {
	Type() string
	Ping() error
}

HealthChecker is responsible for checking certain resources

type HealthService

type HealthService struct {
	LivenessProbe  *Probe
	ReadinessProbe *Probe
}

HealthService is the HTTP handler implementation which wraps the Probe and Checker logic

func (*HealthService) HealthStatus

func (hs *HealthService) HealthStatus(w http.ResponseWriter, r *http.Request)

HealthStatus checks if the application is healthy

func (*HealthService) ReadinessStatus

func (hs *HealthService) ReadinessStatus(w http.ResponseWriter, r *http.Request)

ReadinessStatus checks if the app is ready for accepting request (eg. database is available as well)

type Probe

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

Probe is responsible for executing a series of checks and decide if the service is up or not

func NewProbe

func NewProbe(checkers ...HealthChecker) *Probe

NewProbe is a shortcut for easily creating a new Probe

func (*Probe) Check

func (p *Probe) Check() error

Check executes the underlying health checks

type StatusHealthChecker

type StatusHealthChecker struct {
	Status bool
}

StatusHealthChecker checks the status based on an internal

func (*StatusHealthChecker) Ping

func (s *StatusHealthChecker) Ping() error

Ping checks the internal status and returns an error if it is false

func (*StatusHealthChecker) Type

func (s *StatusHealthChecker) Type() string

Type returns the name of the status checker

Jump to

Keyboard shortcuts

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