health

package
v0.4.8-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHealthCheckNamesConflict = errors.New("health check names conflict")
	ErrHealthCheckFailed        = errors.New("health check failed")
)

Functions

func NewHandler

func NewHandler(conf HandlerConfig) http.HandlerFunc

func NewLivezHandler

func NewLivezHandler() http.HandlerFunc

NewLivezHandler creates a new liveness check handler that can be used to check if the application is running.

func NewReadyzHandler

func NewReadyzHandler(sg storage.Storage) http.HandlerFunc

NewReadyzHandler creates a new readiness check handler that can be used to check if the application is ready to serve traffic. Currently, this feature only contains a storage check and a ping check.

func Register

func Register(r *chi.Mux, sg storage.Storage)

Register registers the livez and readyz handlers to the specified router.

Types

type Check

type Check interface {
	Pass(context.Context) bool
	Name() string
}

Check represents a health check that can be run to check the status of a service.

func NewPingCheck

func NewPingCheck() Check

NewPingCheck creates a new ping health check.

func NewStorageCheck

func NewStorageCheck(sg storage.Storage) Check

func NewStorageCheckHandler

func NewStorageCheckHandler(sg storage.Storage) Check

type CheckStatuses

type CheckStatuses struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCheckStatuses

func NewCheckStatuses(n int) *CheckStatuses

NewCheckStatuses creates a new CheckStatuses instance with the specified capacity.

func (*CheckStatuses) Delete

func (cs *CheckStatuses) Delete(k string)

Delete deletes the specified key from the map.

func (*CheckStatuses) Each

func (cs *CheckStatuses) Each(f func(k string, v bool))

Each calls the specified function for each key/value pair in the map.

func (*CheckStatuses) Get

func (cs *CheckStatuses) Get(k string) (bool, bool)

Get returns the value and existence status for the specified key.

func (*CheckStatuses) Len

func (cs *CheckStatuses) Len() int

Len returns the number of items in the map.

func (*CheckStatuses) Set

func (cs *CheckStatuses) Set(k string, v bool)

Set sets the value for the specified key.

func (*CheckStatuses) String

func (cs *CheckStatuses) String(verbose bool) string

String returns a string representation of the check statuses. If verbose is true, the output includes pass/fail status for each check.

type FailureNotification

type FailureNotification struct {
	Threshold uint32
	Chan      chan error
}

FailureNotification represents the configuration for failure notifications.

type HandlerConfig

type HandlerConfig struct {
	Verbose  bool
	Excludes []string
	Checks   []Check
	FailureNotification
}

HandlerConfig represents the configuration for the health check handler.

type StorageCheck

type StorageCheck struct {
	storage.Storage
}

func (*StorageCheck) Name

func (s *StorageCheck) Name() string

func (*StorageCheck) Pass

func (s *StorageCheck) Pass(ctx context.Context) bool

Jump to

Keyboard shortcuts

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