healthcheck

package
v1.29.0-alpha.128 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package healthcheck xxx

Index

Constants

View Source
const (
	// HttpHealthcheck xxx
	HttpHealthcheck = "http"
	// TcpHealthcheck xxx
	TcpHealthcheck = "tcp"
	// CommandHealthcheck xxx
	CommandHealthcheck = "command"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	IsStarting() bool           // checker is running
	SetHost(host string)        // setting ip/host for checker
	IsHealthy() bool            // get if check is healthy
	TotalTicks() int            // total check ticks
	IsTicks() bool              // is health check
	ConsecutiveFailure() int    // get consecutive failure times
	Failure() int               // total failures
	LastFailureTime() time.Time // last Failure
	LastCheckTime() time.Time   // last check tick
	Start()                     // start checker
	Stop()                      // stop checker
	ReCheck() bool              // ask checker to check
	Pause() error               // pause check
	Resume() error              // arouse checker
	Name() string               // checker name
	Relation() string           // checker relative to container
}

Checker health check interface

func NewCommandChecker

func NewCommandChecker(cmd string, endpoint string, mechanism *TimeMechanism) (Checker, error)

NewCommandChecker create http checker

func NewHTTPChecker

func NewHTTPChecker(container, schema string, port int, path string, mechanism *TimeMechanism,
	notify FailureNotify) (Checker, error)

NewHTTPChecker create http checker

func NewTCPChecker

func NewTCPChecker(container string, port int, mechanism *TimeMechanism, notify FailureNotify) (Checker, error)

NewTCPChecker create TCP checker

type CheckerStat

type CheckerStat struct {
	Started             bool      // status for started
	StartPoint          time.Time // starting time
	LastFailure         time.Time // time record
	LastCheck           time.Time // time record
	Failures            int       // amount of failure
	Ticks               int       // total checks
	ConsecutiveFailures int       // failure
	Healthy             bool      // healthy status
}

CheckerStat checker statistic

func (*CheckerStat) ConsecutiveFailure

func (check *CheckerStat) ConsecutiveFailure() int

ConsecutiveFailure get consecutive failure times

func (*CheckerStat) Failure

func (check *CheckerStat) Failure() int

Failure total failures

func (*CheckerStat) IsHealthy

func (check *CheckerStat) IsHealthy() bool

IsHealthy get if check is healthy

func (*CheckerStat) IsTicks

func (check *CheckerStat) IsTicks() bool

IsTicks xxx

func (*CheckerStat) LastCheckTime

func (check *CheckerStat) LastCheckTime() time.Time

LastCheckTime last check tick

func (*CheckerStat) LastFailureTime

func (check *CheckerStat) LastFailureTime() time.Time

LastFailureTime last Failure

func (*CheckerStat) TotalTicks

func (check *CheckerStat) TotalTicks() int

TotalTicks total check ticks

type CommandChecker

type CommandChecker struct {
	CheckerStat
	// contains filtered or unexported fields
}

CommandChecker check for http protocol health check

func (*CommandChecker) IsStarting

func (check *CommandChecker) IsStarting() bool

IsStarting xxx

func (*CommandChecker) Name

func (check *CommandChecker) Name() string

Name get check name

func (*CommandChecker) Pause

func (check *CommandChecker) Pause() error

Pause pause check

func (*CommandChecker) ReCheck

func (check *CommandChecker) ReCheck() bool

ReCheck ask checker to check

func (*CommandChecker) Relation

func (check *CommandChecker) Relation() string

Relation checker relative to container

func (*CommandChecker) Resume

func (check *CommandChecker) Resume() error

Resume arouse checker

func (*CommandChecker) SetHost

func (check *CommandChecker) SetHost(containerid string)

SetHost setting container_id

func (*CommandChecker) Start

func (check *CommandChecker) Start()

Start start checker

func (*CommandChecker) Stop

func (check *CommandChecker) Stop()

Stop stop checker

type FailureNotify

type FailureNotify func(Checker)

FailureNotify func handler

type HTTPChecker

type HTTPChecker struct {
	CheckerStat
	// contains filtered or unexported fields
}

HTTPChecker check for http protocol health check

func (*HTTPChecker) IsStarting

func (check *HTTPChecker) IsStarting() bool

IsStarting xxx

func (*HTTPChecker) Name

func (check *HTTPChecker) Name() string

Name get check name

func (*HTTPChecker) Pause

func (check *HTTPChecker) Pause() error

Pause pause check

func (*HTTPChecker) ReCheck

func (check *HTTPChecker) ReCheck() bool

ReCheck ask checker to check

func (*HTTPChecker) Relation

func (check *HTTPChecker) Relation() string

Relation checker relative to container

func (*HTTPChecker) Resume

func (check *HTTPChecker) Resume() error

Resume arouse checker

func (*HTTPChecker) SetHost

func (check *HTTPChecker) SetHost(host string)

SetHost setting host / ipaddress

func (*HTTPChecker) Start

func (check *HTTPChecker) Start()

Start start checker

func (*HTTPChecker) Stop

func (check *HTTPChecker) Stop()

Stop stop checker

type TCPChecker

type TCPChecker struct {
	CheckerStat
	// contains filtered or unexported fields
}

TCPChecker create check for tcp port check

func (*TCPChecker) IsStarting

func (check *TCPChecker) IsStarting() bool

IsStarting xxx

func (*TCPChecker) Name

func (check *TCPChecker) Name() string

Name get check name

func (*TCPChecker) Pause

func (check *TCPChecker) Pause() error

Pause pause check

func (*TCPChecker) ReCheck

func (check *TCPChecker) ReCheck() bool

ReCheck ask checker to check

func (*TCPChecker) Relation

func (check *TCPChecker) Relation() string

Relation checker relative to container

func (*TCPChecker) Resume

func (check *TCPChecker) Resume() error

Resume arouse checker

func (*TCPChecker) SetHost

func (check *TCPChecker) SetHost(host string)

SetHost setting host / ipaddress

func (*TCPChecker) Start

func (check *TCPChecker) Start()

Start start checker, must running in indivisual goroutine

func (*TCPChecker) Stop

func (check *TCPChecker) Stop()

Stop stop checker

type TimeMechanism

type TimeMechanism struct {
	// DelaySeconds        int // Amount of time to wait until starting the health checks.
	IntervalSeconds     int // Interval between health checks.
	TimeoutSeconds      int // Amount of time to wait for the health check to complete.
	ConsecutiveFailures int // Number of consecutive failures until signaling kill task.
	GracePeriodSeconds  int // Amount of time to allow failed health checks since launch.
}

TimeMechanism item for checker

Jump to

Keyboard shortcuts

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