Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBackoff ¶
WithBackoff implements retry with exponential backoff using the supplied options as parameters. When fn returns Continue and the number of retry attempts haven't been exhausted, fn is retried. When fn returns Break, retry ends. As a special case, if fn returns Reset, the backoff and retry count are reset to starting values and the next retry occurs immediately. Returns an error if the maximum number of retries is exceeded or if the fn returns an error.
Types ¶
type MaxAttemptsError ¶
type MaxAttemptsError struct {
MaxAttempts int
}
MaxAttemptsError indicates max attempts were exceeded.
func (*MaxAttemptsError) Error ¶
func (re *MaxAttemptsError) Error() string
Error implements error interface.
type Options ¶
type Options struct { Tag string // Tag for helpful logging of backoffs Backoff time.Duration // Default retry backoff interval MaxBackoff time.Duration // Maximum retry backoff interval Constant float64 // Default backoff constant MaxAttempts int // Maximum number of attempts (0 for infinite) UseV1Info bool // Use verbose V(1) level for log messages Stopper *util.Stopper // Optionally end retry loop on stopper signal }
Options provides control of retry loop logic via the WithBackoffOptions method.
type Status ¶
type Status int32
Status is an enum describing the possible statuses of a backoff / retry worker function.
const ( // Break indicates the retry loop is finished and should return // the result of the retry worker function. Break Status = iota // Reset indicates that the retry loop should be reset with // no backoff for an immediate retry. Reset // Continue indicates that the retry loop should continue with // another iteration of backoff / retry. Continue )