Documentation
¶
Index ¶
- type Backoff
- type Conf
- type CtxCancelFn
- type CtxResetWait
- type CtxStructKey
- type ErrorAlreadyRunning
- type ErrorKeywordNotFound
- type ErrorMaxRetryExceeded
- type ErrorPanic
- type ErrorUnexpectedHttpStatus
- type Fn
- type HealthChecker
- type HttpProbeHealthCheckConfig
- type Logger
- type ProbeHealthCheckFn
- type ProbeHealthCheckerConfig
- type TcpProbeHealthCheckConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backoff ¶
func NewInstance ¶
NewInstance creates instance without default configs. Running with all zero values will lead to unexpected behavior. Consider to use New or set values by hand.
type Conf ¶
type Conf struct {
Logger Logger
DisableRecovery bool
// HealthChecker func will be called while waiting for Fn returning errors.
// Once Fn returned anything, the context passed to NewHealthChecker will be canceled.
// If error chan return nil, wait time will be reset. Otherwise, the context passed
// to Fn and HealthChecker will be canceled.
HealthChecker HealthChecker
// InitialDuration means initial wait time, default 1 second
InitialDuration time.Duration
// MaxDuration means maximum retry wait time, default 20 minutes
MaxDuration time.Duration
// MaxRetry, default unlimited
MaxRetry uint
// ExponentFactor default 1
ExponentFactor int
InterConstFactor time.Duration
OuterConstFactor time.Duration
}
type CtxCancelFn ¶
type CtxCancelFn struct {
CtxStructKey[CtxCancelFn, context.CancelFunc]
}
type CtxResetWait ¶
type CtxResetWait struct {
CtxStructKey[CtxResetWait, chan struct{}]
}
type CtxStructKey ¶
type CtxStructKey[Key, Value any] struct{}
func (CtxStructKey[Key, Value]) Get ¶
func (CtxStructKey[Key, Value]) Get(ctx context.Context) (Value, bool)
func (CtxStructKey[Key, Value]) Must ¶
func (c CtxStructKey[Key, Value]) Must(ctx context.Context) Value
type ErrorAlreadyRunning ¶
type ErrorAlreadyRunning struct{}
func (ErrorAlreadyRunning) Error ¶
func (e ErrorAlreadyRunning) Error() string
type ErrorKeywordNotFound ¶
type ErrorKeywordNotFound struct {
Keyword string
}
func (ErrorKeywordNotFound) Error ¶
func (e ErrorKeywordNotFound) Error() string
type ErrorMaxRetryExceeded ¶
type ErrorMaxRetryExceeded struct {
LastError error
}
func (ErrorMaxRetryExceeded) Error ¶
func (e ErrorMaxRetryExceeded) Error() string
type ErrorPanic ¶
func (ErrorPanic) Error ¶
func (e ErrorPanic) Error() string
type ErrorUnexpectedHttpStatus ¶
type ErrorUnexpectedHttpStatus struct {
HttpStatus int
}
func (ErrorUnexpectedHttpStatus) Error ¶
func (e ErrorUnexpectedHttpStatus) Error() string
type HealthChecker ¶
func NewProbeHealthChecker ¶
func NewProbeHealthChecker(fn ProbeHealthCheckFn, conf ProbeHealthCheckerConfig) HealthChecker
type HttpProbeHealthCheckConfig ¶
type HttpProbeHealthCheckConfig struct {
// If http.Client is not nil, some config will not take effect.
Client *http.Client
Timeout time.Duration
FollowRedirect bool
Method string
URL string
Header http.Header
// HttpStatusCode determines which HTTP code is
// considered successful. If HttpStatusCode is 0,
// any status between 200 and 299 is considered a success.
HttpStatusCode int
// If Keyword is empty, the health check will pass only
// when the response body contains the keyword.
// The keyword must not contain line breaks.
Keyword string
}
type ProbeHealthCheckFn ¶
func NewHttpProbeHealthCheckFn ¶
func NewHttpProbeHealthCheckFn(conf HttpProbeHealthCheckConfig) ProbeHealthCheckFn
func NewTcpProbeHealthCheckFn ¶
func NewTcpProbeHealthCheckFn(conf TcpProbeHealthCheckConfig) ProbeHealthCheckFn
Click to show internal directories.
Click to hide internal directories.