health

package
v0.0.0-...-05cee2a Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(c Config)

Types

type CheckResult

type CheckResult struct {
	CheckName string   `json:"name"`
	Status    Status   `json:"status"`
	Error     string   `json:"error,omitempty"`
	Extra     []string `json:"extra,omitempty"`
}

func Ok

func Ok(checkName string, extra []string) CheckResult

func Unhealthy

func Unhealthy(checkName, errorDetails string, extra []string) CheckResult

type Checker

type Checker interface {
	Name() string
	TimeoutSeconds() int
	Run(c chan CheckResult)
}

To create a check without an asynchronous timeout, return 0 for TimeoutSeconds() To create a simple check, you can call CreateHealthCheck or CreateHealthCheckWithTimeout For more control, create your own implementation of the Checker interface

func CreateHealthCheck

func CreateHealthCheck(name string, run HealthCheckFunc) Checker

func CreateHealthCheckWithTimeout

func CreateHealthCheckWithTimeout(name string, timeoutSeconds int, run HealthCheckFunc) Checker

type Config

type Config struct {
	ServiceName string
	Checks      []Checker
}

type Health

type Health struct {
	ServiceName string                 `json:"serviceName"`
	Checks      map[string]CheckResult `json:"checks"`
	Unhealthy   bool                   `json:"-"`
}

func CreateResponse

func CreateResponse(serviceName string) Health

func RunChecks

func RunChecks() Health

func (*Health) AddResult

func (s *Health) AddResult(result CheckResult)

type HealthCheckFunc

type HealthCheckFunc func(name string, out chan CheckResult)

type Status

type Status string
const (
	Status_Ok        Status = "ok"
	Status_Unhealthy Status = "unhealthy"
)

Jump to

Keyboard shortcuts

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