health

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package health provides health check functionality for API components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

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

Checker performs health checks for a component.

func NewChecker

func NewChecker(pinger Pinger, version string) *Checker

NewChecker creates a new health checker.

func (*Checker) Check

func (c *Checker) Check(ctx context.Context) *Response

Check performs all health checks and returns the aggregated response.

func (*Checker) Handler

func (c *Checker) Handler() http.HandlerFunc

Handler returns an HTTP handler for health checks.

func (*Checker) SetTimeout

func (c *Checker) SetTimeout(timeout time.Duration)

SetTimeout sets the timeout for health checks.

type ComponentStatus

type ComponentStatus struct {
	Status  Status `json:"status"`
	Message string `json:"message,omitempty"`
}

ComponentStatus represents the health status of a single component.

type Pinger

type Pinger interface {
	Ping(ctx context.Context) error
}

Pinger is an interface for components that can be pinged.

type Response

type Response struct {
	Status     Status                     `json:"status"`
	Components map[string]ComponentStatus `json:"components"`
	Version    string                     `json:"version"`
	Uptime     string                     `json:"uptime"`
}

Response represents the health check response.

type Status

type Status string

Status represents the health status of a component.

const (
	// StatusHealthy indicates the component is fully operational.
	StatusHealthy Status = "healthy"
	// StatusDegraded indicates the component is operational but with issues.
	StatusDegraded Status = "degraded"
	// StatusUnhealthy indicates the component is not operational.
	StatusUnhealthy Status = "unhealthy"
)

Jump to

Keyboard shortcuts

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