health

package
Version: v0.0.0-...-e689ca2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package health adds methods for checking the health of service dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHealth

func CheckHealth(logger log.Logger, checkers map[string]Checker) bool

CheckHealth checks multiple checkers returning false if any of them fail. CheckHealth logs the reason a checker fails.

func Handler

func Handler(logger log.Logger, checkers map[string]Checker) http.HandlerFunc

Handler returns an http.Handler that checks the status of all the dependencies. Handler responds with either: 200 OK if the server can successfully communicate with it's backends or 500 if any of the backends are reporting an issue.

Types

type Checker

type Checker interface {
	HealthCheck() error
}

Checker returns an error indicating if a service is in an unhealthy state. Checkers should be implemented by dependencies which can fail, like a DB or mail service.

func Nop

func Nop() Checker

Nop creates a noop checker. Useful in tests.

Source Files

Jump to

Keyboard shortcuts

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