health

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"health",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("health")
	}),
	fx.Provide(
		AsHealthProvider(NewDBProvider),
		fx.Private,
	),
	fx.Provide(
		NewService,
	),
)

Functions

func AsHealthProvider

func AsHealthProvider(f any) any

Types

type Check

type Check struct {
	// Overall status of the application.
	// It can be one of the following values: "pass", "warn", or "fail".
	Status Status
	// A map of check names to their respective details.
	Checks Checks
}

Health status of the application.

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 int
	// Status of the check.
	// It can be one of the following values: "pass", "warn", or "fail".
	Status Status
}

Details of a health check.

type Checks

type Checks map[string]CheckDetail

Map of check names to their respective details.

type DBProvider

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

func NewDBProvider

func NewDBProvider(params DBProviderParams) *DBProvider

func (*DBProvider) HealthCheck

func (p *DBProvider) HealthCheck(ctx context.Context) (Checks, error)

func (*DBProvider) Name

func (p *DBProvider) Name() string

type DBProviderParams

type DBProviderParams struct {
	fx.In

	DB *sql.DB
}

type HealthProvider

type HealthProvider interface {
	Name() string
	HealthCheck(ctx context.Context) (Checks, error)
}

type Service

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

func NewService

func NewService(params ServiceParams) *Service

func (*Service) HealthCheck

func (s *Service) HealthCheck(ctx context.Context) (Check, error)

type ServiceParams

type ServiceParams struct {
	fx.In

	HealthProviders []HealthProvider `group:"health-providers"`

	Logger *zap.Logger
}

type Status

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

Jump to

Keyboard shortcuts

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