istio: Index | Files

package retry

import ""


Package Files



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


var ErrConditionNotMet = errors.New("expected condition not met")

func Do Uses

func Do(fn RetriableFunc, options ...Option) (interface{}, error)

Do retries the given function, until there is a timeout, or until the function indicates that it has completed.

func Until Uses

func Until(fn func() bool, options ...Option) error

Until retries the given function until it returns true or hits the timeout timeout

func UntilOrFail Uses

func UntilOrFail(t test.Failer, fn func() bool, options ...Option)

UntilOrFail calls Until, and fails t with Fatalf if it ends up returning an error

func UntilSuccess Uses

func UntilSuccess(fn func() error, options ...Option) error

UntilSuccess retries the given function until success, timeout, or until the passed-in function returns nil.

func UntilSuccessOrFail Uses

func UntilSuccessOrFail(t test.Failer, fn func() error, options ...Option)

UntilSuccessOrFail calls UntilSuccess, and fails t with Fatalf if it ends up returning an error

type Option Uses

type Option func(cfg *config)

Option for a retry operation.

func Converge Uses

func Converge(successes int) Option

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 Delay Uses

func Delay(delay time.Duration) Option

Delay sets the delay between successive retry attempts.

func Message Uses

func Message(errorMessage string) Option

Message defines a more detailed error message to use when failing

func Timeout Uses

func Timeout(timeout time.Duration) Option

Timeout sets the timeout for the entire retry operation.

type RetriableFunc Uses

type RetriableFunc func() (result interface{}, completed bool, err error)

RetriableFunc a function that can be retried.

Package retry imports 4 packages (graph) and is imported by 21 packages. Updated 2020-12-31. Refresh now. Tools for package owners.