diagnose

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 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 Component

type Component interface {
	Diagnose() ComponentReport
}

Component interface for a component health check

type ComponentReport

type ComponentReport struct {
	Status     HealthStatus  `json:"status"`
	Name       string        `json:"name"`
	Message    string        `json:"message"`
	Suggestion string        `json:"suggestion"`
	Latency    time.Duration `json:"latency"`
}

ComponentReport each component report

func NewReport

func NewReport(component string) *ComponentReport

NewReport constructor

func SimpleDiagnose

func SimpleDiagnose(componentName string, check SimpleCheck) ComponentReport

SimpleDiagnose Simple diagnose chack based on a check function that returns an error

func (*ComponentReport) AddLatency

func (c *ComponentReport) AddLatency(start time.Time)

AddLatency add a latency for the start time

func (*ComponentReport) Check

func (c *ComponentReport) Check(err error, message, suggestion string)

Check check for error and add custom message

func (*ComponentReport) MarshalJSON

func (c *ComponentReport) MarshalJSON() ([]byte, error)

MarshalJSON custom json formater

type HealthChecker

type HealthChecker struct {
	Components []Component
}

HealthChecker main health diagnoser

func New

func New() (*HealthChecker, error)

New constructor function for HealthChecker http://confluence.alaudatech.com/pages/viewpage.action?pageId=14123161

func (*HealthChecker) Add

func (h *HealthChecker) Add(com Component) *HealthChecker

Add add component for check

func (*HealthChecker) Check

func (h *HealthChecker) Check() HealthReport

Check starts health check of components

type HealthReport

type HealthReport struct {
	Status  HealthStatus      `json:"status"`
	Details []ComponentReport `json:"details"`
}

HealthReport report struct format

func (*HealthReport) Add

func (h *HealthReport) Add(report ComponentReport)

Add adds a new component report

type HealthStatus

type HealthStatus string

HealthStatus type to create health status

const (
	// StatusOK means the component is K
	StatusOK HealthStatus = "OK"
	// StatusError means there is an error with the component
	StatusError HealthStatus = "ERROR"
)

type SimpleCheck

type SimpleCheck func() error

SimpleCheck simplified health check function for components where if the function returns an error it should be able to distinguish the health status of the component

Jump to

Keyboard shortcuts

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