healthz

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 3 Imported by: 13

Documentation

Index

Constants

View Source
const (
	// Description describes which functionality this health check implements.
	Description = "Ensure service availability."
	// Name is the identifier of the health check. This can be used for emitting
	// metrics.
	Name = "service"
	// SuccessMessage is the message returned in case the health check did not
	// fail.
	SuccessMessage = "Service up."
)

Variables

This section is empty.

Functions

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

Types

type Config

type Config struct {
	Logger micrologger.Logger
}

Config represents the configuration used to create a healthz service.

type Healthz

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

Healthz implements the health service.

func New

func New(config Config) (*Healthz, error)

New creates a new configured healthz service.

func (*Healthz) GetHealthz

func (h *Healthz) GetHealthz(ctx context.Context) (Response, error)

type Response

type Response struct {
	Description string `json:"description" yaml:"description"`
	Failed      bool   `json:"failed" yaml:"failed"`
	Message     string `json:"message" yaml:"message"`
	Name        string `json:"name" yaml:"name"`
}

Response is the response structure each health check returns.

type Responses

type Responses []Response

func (Responses) HasFailed

func (rs Responses) HasFailed() bool

type Service

type Service interface {
	// GetHealthz executes the health check business logic. It always returns a
	// response structure containing information about the system state it checks.
	// GetHealthz only returns an error in case it cannot create its response
	// structure properly. This implies that failed health checks must not be
	// represented by an error being returned, but by the response structure
	// itself.
	GetHealthz(ctx context.Context) (Response, error)
}

Service describes how an implementation of a health check has to be done.

Jump to

Keyboard shortcuts

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