# README
healthcheck
import "github.com/jspc/go-health"
Overview
healthcheck is the reference implementation of the Culture Trip Healthcheck API.
It can be instantiated as per:
package main
import (
"github.com/jspc/go-health"
)
func main() {
h := healthcheck.New()
}
It exposes a fasthttp handler which can be mounted to do stuff
Index
Package files
api.go doc.go healthcheck.go healthchecks.go version.go
Variables
var (
// Tick is the time to wait between healthcheck tests
Tick = 10 * time.Second
)
type Healthcheck
type Healthcheck struct {
// Name is a simple string to help explain the point of the healthcheck
// It doesn't have to even be unique- it's just to make output more
// readable
Name string `json:"name"`
// Readiness and Liveness determines what check endpoints are affected by
// what healthchecks- it's also possible to set these as both false- this
// will, essentially, make a healthcheck advisory only
Readiness bool `json:"readiness"`
Liveness bool `json:"liveness"`
// RunbookItem should point to the url and anchor, where possible, of
// the healthcheck/ dependency. It may be in the runbook of the service
// or it may be another runbook
RunbookItem string `json:"runbook_item"`
// F is the function that a healthcheck runs. It returns true for a
// successful healthcheck, and false for a failing healthcheck.
// It also returns optional output.
F func() (bool, interface{}) `json:"-"`
// The following are overwritten when a healthcheck is run
State string `json:"state"` // enum: not_run, running, run
LastRun time.Time `json:"last_run"`
Duration float64 `json:"duration_ms"`
Success bool `json:"success"`
Output interface{} `json:"output"`
}
Healthcheck represents an individual healthcheck
func (*Healthcheck) Run
func (h *Healthcheck) Run()
Run will.... run the healthcheck
type Healthchecks
type Healthchecks struct {
ReportTime time.Time `json:"report_as_of"`
Healthchecks []Healthcheck `json:"healthchecks"`
// contains filtered or unexported fields
}
Healthchecks represent the state of a run set of healthchecks and
func New
func New(v Version) Healthchecks
New returns a Healthchecks object which exposes an API and contains timers and logic for running healthchecks
func (*Healthchecks) Add
func (h *Healthchecks) Add(hc Healthcheck)
Add takes a Healthcheck and enrolls it into the Healthchecks thing
func (Healthchecks) Handle
func (h Healthchecks) Handle(ctx *fasthttp.RequestCtx)
Handle provides an API endpoint/ router for healthcheck endpoints which can be mounted into ct fasthttp apps.
It is compliant with github.com/beamly/go-http-middleware
func (*Healthchecks) Start
func (h *Healthchecks) Start()
Start will run a timer doing healthchecks and stuff
type Version
type Version struct {
Name string `json:"release_name"`
Built int64 `json:"built"`
CircleSha string `json:"version"`
Oracle string `json:"oracle"`
Runbook string `json:"runbook"`
Squad string `json:"squad"`
}
Version exposes the version, version config, and basic links to bits and bobs it needs
Generated by godoc2md