healthfx

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 11 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsProvider

func AsProvider(f any) any

func Module

func Module() fx.Option

Types

type CheckDetail

type CheckDetail struct {
	// A human-readable description of the check.
	Description string
	// Unit of measurement for the observed value.
	ObservedUnit string
	// Observed value of the check.
	ObservedValue any
	// Status of the check.
	// It can be one of the following values: "pass", "warn", or "fail".
	Status Status
}

CheckDetail of a health check.

type CheckResult

type CheckResult struct {
	// A map of check names to their respective details.
	Checks Checks
}

CheckResult represents the result of a set of health checks.

func (CheckResult) Status

func (c CheckResult) Status() Status

Status returns the overall status of the application. It can be one of the following values: "pass", "warn", or "fail".

type Checks

type Checks map[string]CheckDetail

Checks is a map of check names to their respective details.

type Provider

type Provider interface {
	// Name returns the unique identifier for this provider.
	Name() string

	// StartedProbe checks if the provider has successfully started.
	StartedProbe(ctx context.Context) (Checks, error)
	// ReadyProbe checks if the provider is ready to handle requests.
	ReadyProbe(ctx context.Context) (Checks, error)
	// LiveProbe checks if the provider is still alive and functioning.
	LiveProbe(ctx context.Context) (Checks, error)
}

Provider defines the interface for health check providers. Each provider can implement startup, readiness, and liveness probes. Probes should return an empty Checks map (not nil) when there are no checks to report. Returning an error indicates the probe failed to execute, not that checks failed.

type Service

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

func NewService

func NewService(providers []Provider, version Version, logger *zap.Logger) *Service

func (*Service) CheckLiveness

func (s *Service) CheckLiveness(ctx context.Context) CheckResult

func (*Service) CheckReadiness

func (s *Service) CheckReadiness(ctx context.Context) CheckResult

func (*Service) CheckStartup

func (s *Service) CheckStartup(ctx context.Context) CheckResult

func (*Service) Register

func (s *Service) Register(p Provider)

func (*Service) Version added in v0.1.0

func (s *Service) Version() Version

type Status

type Status string
const (
	StatusPass Status = "pass"
	StatusWarn Status = "warn"
	StatusFail Status = "fail"
)

type Version added in v0.1.0

type Version struct {
	Version   string // semver
	ReleaseID int    // build number
	BuildDate string // ISO 8601
	GitCommit string // commit hash
	GoVersion string // go version
}

Version is the current version of the application.

func (Version) String added in v0.1.0

func (v Version) String() string

Jump to

Keyboard shortcuts

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