health

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package health provides health check functionality for TokMan.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Status     Status                 `json:"status"`
	Version    string                 `json:"version"`
	Timestamp  time.Time              `json:"timestamp"`
	Components []Component            `json:"components"`
	System     map[string]interface{} `json:"system,omitempty"`
}

Check represents a health check result

type CheckFunc

type CheckFunc func(ctx context.Context) Component

CheckFunc is a function that performs a health check

type Checker

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

Checker performs health checks

func NewChecker

func NewChecker(cfg *config.Config, tracker *tracking.Tracker, version string) *Checker

NewChecker creates a new health checker

func (*Checker) Check

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

Check performs all health checks

func (*Checker) CheckLiveness

func (c *Checker) CheckLiveness(ctx context.Context) Component

CheckLiveness performs a lightweight liveness check

func (*Checker) CheckReadiness

func (c *Checker) CheckReadiness(ctx context.Context) Component

CheckReadiness performs a readiness check

func (*Checker) HealthHandler

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

HealthHandler returns an HTTP handler for health checks

func (*Checker) LivenessHandler

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

LivenessHandler returns an HTTP handler for Kubernetes liveness probes

func (*Checker) ReadinessHandler

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

ReadinessHandler returns an HTTP handler for Kubernetes readiness probes

func (*Checker) RegisterCheck

func (c *Checker) RegisterCheck(name string, fn CheckFunc)

RegisterCheck registers a custom health check

type Component

type Component struct {
	Name      string                 `json:"name"`
	Status    Status                 `json:"status"`
	Message   string                 `json:"message,omitempty"`
	Timestamp time.Time              `json:"timestamp"`
	Details   map[string]interface{} `json:"details,omitempty"`
	Latency   time.Duration          `json:"latency_ms"`
}

Component represents a health check component

type Status

type Status string

Status represents the health status of a component

const (
	StatusHealthy   Status = "healthy"
	StatusDegraded  Status = "degraded"
	StatusUnhealthy Status = "unhealthy"
)

Jump to

Keyboard shortcuts

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