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) 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 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.