health

package
v0.6.21 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package health is the single source of a service's health: probes are registered by kind, their composite status is cached in xprobe states, and grpc.health.v1, the HTTP probe endpoints and the Consul check all read the same states.

Each kind is driven by an xprobe runner, which serializes evaluation: a periodic tick and a Serving flip never interleave, so a slow check started before the gate opened cannot overwrite the fresher result.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Health

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

Health owns probe states. The readiness state is the registry's "" entry, which grpc.health.v1 reports and Consul checks.

func New

func New(log *xlog.Logger, interval, timeout time.Duration) *Health

New creates the health component: every kind is evaluated each interval, one evaluation bounded by timeout (at most interval; 0 means interval).

func (*Health) Add

func (h *Health) Add(k Kind, p probe.Probe)

Add registers a probe of the given kind; call before Start.

func (*Health) GRPC

func (h *Health) GRPC() hv1.HealthServer

GRPC is the grpc.health.v1 server over the cached readiness.

func (*Health) HTTP

func (h *Health) HTTP() http.Handler

HTTP serves the cached states at the xprobe default paths.

func (*Health) Interval

func (h *Health) Interval() time.Duration

Interval between evaluations.

func (*Health) Serving

func (h *Health) Serving(ctx context.Context, on bool)

Serving flips the SDK's own gate and re-evaluates readiness and startup immediately.

func (*Health) Start

func (h *Health) Start(ctx context.Context, g node.Group) error

Start builds the composites and re-evaluates each kind every interval; a check may take up to the timeout.

type Kind

type Kind int

Kind of probe.

const (
	Live Kind = iota
	Ready
	Startup
)

func (Kind) String

func (k Kind) String() string

Jump to

Keyboard shortcuts

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