healthcheck

package
v0.0.0-...-ed26957 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAllCheckTriesFailed = errors.New("all check tries failed")
View Source
var ErrHTTPStatusNotOK = errors.New("HTTP response status is not OK")

Functions

This section is empty.

Types

type Checker

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

func NewChecker

func NewChecker(logger Logger) *Checker

func (*Checker) SetConfig

func (c *Checker) SetConfig(tlsDialAddrs []string, icmpTargets []netip.Addr,
	smallCheckType string, startupOnFail bool,
)

SetConfig sets the following: - TCP+TLS dial addresses - ICMP echo IP addresses to target - the desired small check type (dns or icmp) - whether to startup the periodic checks if the startup check fails. This function MUST be called before calling Checker.Start.

func (*Checker) Start

func (c *Checker) Start(ctx context.Context) (runError <-chan error, err error)

Start starts the Checker which behaves differently according to its internal field startupOnFail, which is set by calling Checker.SetConfig.

By default, startupOnFail should be false and the behavior is as follows: A blocking 6s-timed TCP+TLS check is performed first. If it fails, an error is returned and the Checker is not started. On success, it starts the periodic checks in a separate goroutine, returning the runError error channel and a nil error.

If startupOnFail is true, the behavior is as follows: A blocking 6s-timed TCP+TLS check is performed first. If it fails, the error is sent to the runError channel, but no error is returned and the Checker continues to start the periodic checks in a separate goroutine, returning the runError error channel and a nil error.

The periodic checks consist in: - a "small" ICMP echo check every minute - a "full" TCP+TLS check every 5 minutes

The Checker has to be ultimately stopped by calling Checker.Stop.

func (*Checker) Stop

func (c *Checker) Stop() error

type Client

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

func NewClient

func NewClient(httpClient *http.Client) *Client

func (*Client) Check

func (c *Client) Check(ctx context.Context, url string) error

type Logger

type Logger interface {
	Debugf(format string, args ...any)
	Info(s string)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Error(s string)
}

type Server

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

func NewServer

func NewServer(config settings.Health, logger Logger) *Server

func (*Server) Run

func (s *Server) Run(ctx context.Context, done chan<- struct{})

func (*Server) SetError

func (s *Server) SetError(err error)

type StatusApplier

type StatusApplier interface {
	ApplyStatus(ctx context.Context, status models.LoopStatus) (
		outcome string, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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