Help us shape the future of Go! Take the 2026 Go Developer Survey

health

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func(context.Context) error

CheckFunc runs a health or readiness check.

type CheckResult

type CheckResult struct {
	Name       string `json:"name"`
	Status     string `json:"status"`
	Error      string `json:"error,omitempty"`
	DurationMS int64  `json:"duration_ms"`
}

CheckResult reports a single check.

type Option

type Option func(*Registry)

Option configures a Registry.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets a timeout for all checks.

type Registry

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

Registry stores health and readiness checks.

func New

func New(options ...Option) *Registry

New creates a Registry.

func (*Registry) Add

func (r *Registry) Add(name string, check CheckFunc)

Add registers a liveness check.

func (*Registry) AddReady

func (r *Registry) AddReady(name string, check CheckFunc)

AddReady registers a readiness check.

func (*Registry) Handler

func (r *Registry) Handler() http.Handler

Handler returns a handler for liveness checks.

func (*Registry) ReadyHandler

func (r *Registry) ReadyHandler() http.Handler

ReadyHandler returns a handler for readiness checks.

func (*Registry) Remove

func (r *Registry) Remove(name string)

Remove deletes a liveness check.

func (*Registry) RemoveReady

func (r *Registry) RemoveReady(name string)

RemoveReady deletes a readiness check.

type Report

type Report struct {
	Status      string        `json:"status"`
	Checks      []CheckResult `json:"checks"`
	DurationMS  int64         `json:"duration_ms"`
	CheckedAt   time.Time     `json:"checked_at"`
	ChecksReady bool          `json:"ready"`
}

Report describes health status.

Jump to

Keyboard shortcuts

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