health

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package health provides health check and readiness probe support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name        string        `json:"name"`
	Status      Status        `json:"status"`
	Message     string        `json:"message,omitempty"`
	LastChecked time.Time     `json:"last_checked"`
	Duration    time.Duration `json:"duration_ms,omitempty"`
}

Check represents a health check.

type Checker

type Checker func(ctx context.Context) Check

Checker is a function that performs a health check.

func APIKeyChecker

func APIKeyChecker(provider, key string) Checker

APIKeyChecker checks if an API key is configured.

func DiskSpaceChecker

func DiskSpaceChecker(minFreeGB int) Checker

DiskSpaceChecker checks available disk space.

type Registry

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

Registry manages health checks.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new health check registry.

func (*Registry) Register

func (r *Registry) Register(name string, checker Checker)

Register registers a health check.

func (*Registry) Result

func (r *Registry) Result(name string) (Check, bool)

Result returns the result of a specific check.

func (*Registry) Run

func (r *Registry) Run(ctx context.Context) map[string]Check

Run runs all health checks.

func (*Registry) Status

func (r *Registry) Status() Status

Status returns the overall health status.

type Status

type Status string

Status represents health status.

const (
	Healthy   Status = "healthy"
	Unhealthy Status = "unhealthy"
	Degraded  Status = "degraded"
)

Jump to

Keyboard shortcuts

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