healthcheck

package
v1.112.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error class for this package.
	Error = errs.Class("healthcheck")
	// ErrCheckExists is returned when a check with the same name already exists.
	ErrCheckExists = Error.New("check with name already exists")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled bool   `help:"Whether the health check server is enabled" default:"false"`
	Address string `help:"The address to listen on for health check server" default:":10500"`
}

Config is the configuration for healthcheck server.

type HealthCheck

type HealthCheck interface {
	// Healthy returns true if the service is healthy.
	Healthy(ctx context.Context) bool
	// Name returns the name of the service being checked.
	Name() string
}

HealthCheck is an interface that defines the methods for a health check.

type Server

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

Server handles HTTP request for health Server.

func NewServer

func NewServer(log *zap.Logger, listener net.Listener, checks ...HealthCheck) *Server

NewServer creates a new HTTP Server.

func (*Server) AddCheck

func (s *Server) AddCheck(check HealthCheck) error

AddCheck adds a health check to the server.

func (*Server) Close

func (s *Server) Close() error

Close stops the server.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the health check server.

func (*Server) TestGetAddress

func (s *Server) TestGetAddress() string

TestGetAddress returns the address of this server for tests.

Jump to

Keyboard shortcuts

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