Documentation ¶
Index ¶
- Constants
- Variables
- func Until(fn func() bool, options ...Option) error
- func UntilComplete(fn RetriableFunc, options ...Option) (any, error)
- func UntilOrFail(t test.Failer, fn func() bool, options ...Option)
- func UntilSuccess(fn func() error, options ...Option) error
- func UntilSuccessOrFail(t test.Failer, fn func() error, options ...Option)
- type Option
- type RetriableFunc
Constants ¶
const ( // DefaultTimeout the default timeout for the entire retry operation DefaultTimeout = time.Second * 30 // DefaultDelay the default delay between successive retry attempts DefaultDelay = time.Millisecond * 10 // DefaultConverge the default converge, requiring something to succeed one time DefaultConverge = 1 )
Variables ¶
var ErrConditionNotMet = errors.New("expected condition not met")
Functions ¶
func UntilComplete ¶
func UntilComplete(fn RetriableFunc, options ...Option) (any, error)
UntilComplete retries the given function, until there is a timeout, or until the function indicates that it has completed. Once complete, the returned value and error are returned.
func UntilOrFail ¶
UntilOrFail calls Until, and fails t with Fatalf if it ends up returning an error
func UntilSuccess ¶
UntilSuccess retries the given function until success, timeout, or until the passed-in function returns nil.
Types ¶
type Option ¶
type Option func(cfg *config)
Option for a retry operation.
func BackoffDelay ¶
func Converge ¶
Converge sets the number of successes in a row needed to count a success. This is useful to avoid the case where tests like `coin.Flip() == HEADS` will always return success due to random variance.
func MaxAttempts ¶
MaxAttempts allows defining a maximum number of attempts. If unset, only timeout is considered.
type RetriableFunc ¶
RetriableFunc a function that can be retried.