health

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package health contains helpers for constructing health checks.

Index

Constants

This section is empty.

Variables

View Source
var ErrDown = errors.New("application down")

ErrDown is the error returned when an HTTP health check returns a non-200 status.

View Source
var Flags = flag.Flags{
	&flag.Boolean{
		Name:        "health-check-disabled",
		Usage:       "Disables the health check endpoint",
		EnvVar:      "HEALTH_CHECK_DISABLED",
		Destination: &disabled,
		Hidden:      true,
	},
}

Flags contains all command-line flags that can be used to configure health checks.

Functions

func AddCheck

func AddCheck(name string, fn func() error)

AddCheck adds a status check to the status status. If the provided function returns an error the check is deemed unhealthy.

func PerformCheck

func PerformCheck(ctx context.Context) error

PerformCheck performs an HTTP health check on localhost:8081/__/health. It returns an error if the health check endpoint returns a non-200 status code.

func RegisterGRPCHealthServer

func RegisterGRPCHealthServer(svr *grpc.Server) *health.Server

RegisterGRPCHealthServer registers a gRPC health server implementation onto the provided gRPC server.

func ServeGRPC

func ServeGRPC(ctx context.Context, svr *health.Server) error

ServeGRPC periodically updates the status of the health server based on the result of the current health. If any components are marked as down, the status is changed to NOT_SERVING. This function blocks until the provided context is cancelled.

func ServeHTTP

func ServeHTTP(r *mux.Router)

ServeHTTP adds the status check endpoint to the given router.

Types

This section is empty.

Jump to

Keyboard shortcuts

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