Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do execute the specified function at most maxTries times until it succeeds or got canceled
func Run ¶
Run is Deprecated, try to use Do instead. Run retries the specified function on error for at most maxRetries times. It stops retry if the returned error is context.Canceled or context.DeadlineExceeded.
func RunWithInfiniteRetry ¶
func RunWithInfiniteRetry(initialInterval time.Duration, f func() error, notifyFunc func(elapsed time.Duration)) error
RunWithInfiniteRetry is Deprecated, try to use instead Do WithInfiniteTries option instead. RunWithInfiniteRetry retries the specified function indefinitely, until a backoff.PermanentError is encountered. notifyFunc will be called each time before sleeping with the total elapsed time.
Types ¶
type IsRetryable ¶
IsRetryable checks the error is safe or worth to retry, eg. "context.Canceled" better not retry
type Option ¶
type Option func(*retryOptions)
Option ...
func WithBackoffBaseDelay ¶
WithBackoffBaseDelay configures the initial delay, if delayInMs <= 0 "defaultBackoffBaseInMs" will be used
func WithBackoffMaxDelay ¶
WithBackoffMaxDelay configures the maximum delay, if delayInMs <= 0 "defaultBackoffCapInMs" will be used
func WithInfiniteTries ¶
func WithInfiniteTries() Option
WithInfiniteTries configures to retry forever (math.MaxInt64 times) till success or got canceled
func WithIsRetryableErr ¶
func WithIsRetryableErr(f IsRetryable) Option
WithIsRetryableErr configures the error should retry or not, if not set, retry by default
func WithMaxTries ¶
WithMaxTries configures maximum tries, if tries <= 0 "defaultMaxTries" will be used