health

package
v1.38.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package health provides HTTP health check endpoints for Kubernetes-style liveness and readiness probes.

Stability: stable

Package health provides HTTP health check endpoints for Kubernetes-style liveness and readiness probes.

NewServer creates a Server with /healthz (liveness) and /readyz (readiness) endpoints. Readiness checks are configurable via AddReadinessCheck.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func() error

CheckFunc is a function that returns nil when healthy or an error when not.

func EngineCheck

func EngineCheck(engine *compute.CPUEngine[float32], timeout time.Duration) CheckFunc

EngineCheck returns a CheckFunc that verifies a float32 CPUEngine is operational by performing a small tensor addition. The check fails if the operation takes longer than the given timeout or returns an error.

func EngineCheckGeneric

func EngineCheckGeneric[T tensor.Numeric](engine *compute.CPUEngine[T], ops numeric.Arithmetic[T], timeout time.Duration) CheckFunc

EngineCheckGeneric returns a CheckFunc that verifies a generic CPUEngine is operational by performing a small tensor fill and zero.

type Option added in v1.12.0

type Option func(*Server)

Option configures a Server.

func WithPprof added in v1.12.0

func WithPprof() Option

WithPprof enables /debug/pprof/ endpoints on the health server. By default, pprof endpoints are not registered.

type Response

type Response struct {
	Status string            `json:"status"`
	Checks map[string]string `json:"checks,omitempty"`
}

Response is the JSON body returned by health endpoints.

type Server

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

Server provides HTTP health check endpoints.

func NewServer

func NewServer(logger log.Logger, opts ...Option) *Server

NewServer creates a new health check server using the given logger. Use WithPprof() to opt in to /debug/pprof/ endpoints.

func (*Server) AddReadinessCheck

func (s *Server) AddReadinessCheck(name string, check CheckFunc)

AddReadinessCheck registers a named readiness check. All registered checks must pass for the /readyz endpoint to return 200 OK.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns an http.Handler with /healthz and /readyz routes. When WithPprof was passed to NewServer, /debug/pprof/ routes are also registered.

Jump to

Keyboard shortcuts

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