health

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 1 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter struct {
	// contains filtered or unexported fields
}

Counter represents an error tolerant health counter, which allows failures in short time and periodically remind unhealthy if unrecovered in time.

func (*Counter) IsSuccess

func (counter *Counter) IsSuccess() bool

IsSuccess indicates whether any failure occurred.

func (*Counter) OnFailure

func (counter *Counter) OnFailure(config CounterConfig) (unhealthy bool, unrecovered bool, failures uint64)

OnFailure marks failure status and return unhealthy information.

`unhealthy`: indicates continous failures in a long time.

`unrecovered`: indicates continous failures and unrecovered in a long time.

`failures`: indicates the number of failures so far.

func (*Counter) OnSuccess

func (counter *Counter) OnSuccess(config CounterConfig) (recovered bool, failures uint64)

OnSuccess erases failure status and return recover information if any.

`recovered`: indicates if recovered from unhealthy status.

`failures`: indicates the number of failures before success.

type CounterConfig

type CounterConfig struct {
	Threshold uint64 `default:"60"` // report unhealthy if threshold reached
	Remind    uint64 `default:"60"` // remind unhealthy if unrecovered for a long time
}

type TimedCounter

type TimedCounter struct {
	// contains filtered or unexported fields
}

TimedCounter represents an error tolerant health counter, which allows failures in short time and periodically remind unhealthy if unrecovered in time.

func (*TimedCounter) IsSuccess

func (counter *TimedCounter) IsSuccess() bool

IsSuccess indicates whether any failure occurred.

func (*TimedCounter) OnFailure

func (counter *TimedCounter) OnFailure(config TimedCounterConfig) (unhealthy bool, unrecovered bool, elapsed time.Duration)

OnFailure marks failure status and return unhealthy information.

`unhealthy`: indicates continous failures in a long time.

`unrecovered`: indicates continous failures and unrecovered in a long time.

`elapsed`: indicates the duration since the first failure time.

func (*TimedCounter) OnSuccess

func (counter *TimedCounter) OnSuccess(config TimedCounterConfig) (recovered bool, elapsed time.Duration)

OnSuccess erases failure status and return recover information if any.

`recovered`: indicates if recovered from unhealthy status.

`elapsed`: indicates the duration since the first failure time.

type TimedCounterConfig

type TimedCounterConfig struct {
	Threshold time.Duration `default:"1m"` // report unhealthy if threshold reached
	Remind    time.Duration `default:"5m"` // remind unhealthy if unrecovered for a long time
}

Jump to

Keyboard shortcuts

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