health

package
v0.0.0-...-79e566f Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name string
	Exec Exec
	// contains filtered or unexported fields
}

Check defines a health check

func NewCheck

func NewCheck(name string, exec Exec) *Check

NewCheck creates a fresh Check

func (*Check) GetResult

func (c *Check) GetResult() *Result

GetResult returns a copy of the health check's current Result

type Checker

type Checker interface {
	AddCheck(name string, exec Exec) *Check
	GetResult(name string) *Result
	Run(interval time.Duration, count int64)
	RunAsync(interval time.Duration, count int64)
	Stop()
	DoChecks()
}

Checker defines the health checker interface

func NewChecker

func NewChecker() Checker

NewChecker creates a new health checker

type Exec

type Exec func() (Status, string)

Exec defines the health check interface

type Result

type Result struct {
	LastStatus  Status
	LastMessage string
	LastCheck   time.Time
	Count       int64
}

Result stores the latest health check result

type Status

type Status int

Status defines the type for a health check status

const (
	// Ok means everything is fine
	Ok Status = 0

	// Warning means it's working, but a condition exists that could lead to a failure
	Warning Status = 1

	// Failure means something went wrong
	Failure Status = 2
)

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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