package health

import "github.com/golang/gddo/internal/health"

Package health provides health check handlers.

Index

Functions

func HandleLive

func HandleLive(w http.ResponseWriter, _ *http.Request)

HandleLive is an http.HandleFunc that handles liveness checks by immediately responding with an HTTP 200 status.

Types

type Checker

type Checker interface {
	CheckHealth() error
}

Checker wraps the CheckHealth method.

CheckHealth returns nil if the resource is healthy, or a non-nil error if the resource is not healthy. CheckHealth must be safe to call from multiple goroutines.

type Handler

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

Handler is an HTTP handler that reports on the success of an aggregate of Checkers. The zero value is always healthy.

func (*Handler) Add

func (h *Handler) Add(c Checker)

Add adds a new check to the handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, _ *http.Request)

ServeHTTP returns 200 if it is healthy, 500 otherwise.

Source Files

health.go

Version
v0.0.0-20210115222349-20d68f94ee1f (latest)
Published
Jan 15, 2021
Platform
linux/amd64
Imports
2 packages
Last checked
1 day ago

Tools for package owners.