health

package
v1.0.86 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package health provides functionality for constructing a health check endpoint.

Index

Constants

View Source
const (
	// OK is a healthy status
	OK = "Healthy"
	// WARNING is a warning status
	WARNING = "Warning"
	// CRITICAL is a critical status
	CRITICAL = "Critical"
)

Variables

This section is empty.

Functions

func AddServiceCheck

func AddServiceCheck(checks Checks)

AddServiceCheck inspects all other checks in the map and adds a "service" entry with the highest error level found.

func CreateHealthHandler

func CreateHealthHandler(checker Checker) func(http.ResponseWriter, *http.Request)

CreateHealthHandler takes a health checker and returns an endpoint for health checks

func CreateProbeHandler

func CreateProbeHandler(checker Checker) func(http.ResponseWriter, *http.Request)

CreateProbeHandler takes a health checker and returns an endpoint for probe checks which return different http statuses

Types

type Check

type Check struct {
	Name        string                 `json:"name"`
	Status      string                 `json:"status"`
	Description string                 `json:"description"`
	Data        map[string]interface{} `json:"data"`
}

Check represents each individual health check

type Checker

type Checker interface {
	GetChecks() Checks
	GetResponse(Checks) *Response
}

Checker is an interface for returning healthchecks

type Checks

type Checks []*Check

Checks are a set of named Check pointers

type Response

type Response struct {
	Name    string `json:"name"`
	Status  string `json:"status"`
	Version string `json:"version"`
	Checks  Checks `json:"checks"`
}

Response represents the top-level data structure returned from the API

Jump to

Keyboard shortcuts

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