Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsProvider ¶
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 (*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