health

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// INIT means it is starting
	INIT = Status("INIT")
	// UP means it is healthy
	UP = Status("UP")
	// DOWN means it is unhealthy
	DOWN = Status("DOWN")
)

Functions

func AddLivenessIndicator

func AddLivenessIndicator(name string, idc Indicator)

AddLivenessIndicator register health.Indicator for liveness check.It's not concurrent-safe,so please invoke it ONLY in init method.

func AddLivenessIndicatorFunc

func AddLivenessIndicatorFunc(name string, f func() (string, map[string]interface{}))

AddLivenessIndicatorFunc register health.Indicator for liveness check.Indicator.It's not concurrent-safe,so please invoke it ONLY in init method.

func AddReadinessIndicator

func AddReadinessIndicator(name string, idc Indicator)

AddReadinessIndicator register health.Indicator for readiness check.Indicator.It's not concurrent-safe,so please invoke it ONLY in init method.

func AddReadinessIndicatorFunc

func AddReadinessIndicatorFunc(name string, f func() (string, map[string]interface{}))

AddReadinessIndicatorFunc register health.Indicator for readiness check.Indicator.It's not concurrent-safe,so please invoke it ONLY in init method.

Types

type Details

type Details = map[string]interface{}

Details hold additional contextual details about the health of a component.

func NewDetails

func NewDetails() Details

type Endpoint

type Endpoint struct {
}

func NewEndpoint

func NewEndpoint() *Endpoint

func (*Endpoint) Handle

func (e *Endpoint) Handle(ctx context.Context, params http.ParamsScanner) (map[string]interface{}, error)

Handle will check health status.The structure of the returned map is like:

{
 "status": "DOWN",
 "components": {
   "readinessProbe": {
     "status": "DOWN",
     "details": {}
   }
 }
}

type Health

type Health struct {
	Status  Status  `json:"status"`
	Details Details `json:"details,omitempty"`
}

Health carries information about the health of a component. Details are optional.

func NewHealth

func NewHealth(status Status) Health

func (*Health) GetDetail

func (h *Health) GetDetail(k string) interface{}

GetDetail returns the detailed message indexed by k.

func (*Health) SetDetail

func (h *Health) SetDetail(k string, v interface{})

SetDetail sets a message v into the health details, indexed by k. Note that the previous message of k, if exists, will be overriden. v MUST be a valid json marshable type, otherwise runtime panic or error occurs which fails the actuator health API.

type Indicator

type Indicator interface {
	Report() (status Status, details map[string]interface{})
}

Indicator report the Status and Details for Endpoint.

type IndicatorAdapter

type IndicatorAdapter func() (string, map[string]interface{})

func (IndicatorAdapter) Report

func (ca IndicatorAdapter) Report() (status Status, details map[string]interface{})

type Status

type Status = string

Status is the enumeration value of component health status.

Jump to

Keyboard shortcuts

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