health

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 3 Imported by: 0

README

internal/health

Logic overview

The health package evaluates runtime dependency health and serves health endpoints.

  • StatusEvaluator calculates readiness and mode (healthy, degraded, unhealthy) from role-aware inputs.
  • NewHandler exposes /livez, /readyz, and /healthz.
  • /healthz returns full JSON status including component-level booleans.

API reference

Types
  • Role: runtime role enum (leader, follower).
  • Mode: health mode enum (healthy, degraded, unhealthy).
  • Input: dependency state used by evaluator.
  • Status: evaluated health result (Role, Mode, Ready, Components).
  • Provider: interface for runtime status providers used by HTTP handler.
  • StatusEvaluator: role-aware health evaluation engine.
Functions
  • NewStatusEvaluator() *StatusEvaluator: constructs evaluator.
  • NewHandler(provider Provider) http.Handler: constructs health endpoint handler.
Methods
  • (*StatusEvaluator) Evaluate(input Input) Status: computes readiness/mode and component map.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(provider Provider) http.Handler

NewHandler returns the health HTTP handler with /livez, /readyz, and /healthz endpoints.

Types

type Input

type Input struct {
	Role                 Role
	RedisHealthy         bool
	AMQPHealthy          bool
	SchedulerHealthy     bool
	GitHubClientUsable   bool
	ConsumerHealthy      bool
	ExporterHealthy      bool
	GitHubHealthy        bool
	AdditionalComponents map[string]bool
}

Input represents dependency states used for health evaluation.

type Mode

type Mode string

Mode indicates high-level health mode.

const (
	// ModeHealthy indicates all required dependencies are healthy.
	ModeHealthy Mode = "healthy"
	// ModeDegraded indicates the app is running but a non-readiness dependency is degraded.
	ModeDegraded Mode = "degraded"
	// ModeUnhealthy indicates a required dependency is unhealthy.
	ModeUnhealthy Mode = "unhealthy"
)

type Provider

type Provider interface {
	CurrentStatus(ctx context.Context) Status
}

Provider supplies current health status.

type Role

type Role string

Role identifies the runtime role for readiness evaluation.

const (
	// RoleLeader is the leader role.
	RoleLeader Role = "leader"
	// RoleFollower is the follower role.
	RoleFollower Role = "follower"
)

type Status

type Status struct {
	Role       Role            `json:"role"`
	Mode       Mode            `json:"mode"`
	Ready      bool            `json:"ready"`
	Components map[string]bool `json:"components"`
}

Status represents evaluated application health.

type StatusEvaluator

type StatusEvaluator struct{}

StatusEvaluator evaluates role-aware health and readiness.

func NewStatusEvaluator

func NewStatusEvaluator() *StatusEvaluator

NewStatusEvaluator creates a health evaluator.

func (*StatusEvaluator) Evaluate

func (e *StatusEvaluator) Evaluate(input Input) Status

Evaluate evaluates readiness and mode from dependency state.

Jump to

Keyboard shortcuts

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