retry

package
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoWithRetry

func DoWithRetry(t *testing.T, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) string

Run the specified action. If it returns a value, return that value. If it returns a FatalError, return that error immediately. If it returns any other type of error, sleep for sleepBetweenRetries and try again, up to a maximum of maxRetries retries. If maxRetries is exceeded, fail the test.

func DoWithRetryE

func DoWithRetryE(t *testing.T, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) (string, error)

Run the specified action. If it returns a value, return that value. If it returns a FatalError, return that error immediately. If it returns any other type of error, sleep for sleepBetweenRetries and try again, up to a maximum of maxRetries retries. If maxRetries is exceeded, return a MaxRetriesExceeded error.

func DoWithTimeout

func DoWithTimeout(t *testing.T, actionDescription string, timeout time.Duration, action func() (string, error)) string

Run the specified action and wait up to the specified timeout for it to complete. Return the output of the action if it completes on time or fail the test otherwise.

func DoWithTimeoutE

func DoWithTimeoutE(t *testing.T, actionDescription string, timeout time.Duration, action func() (string, error)) (string, error)

Run the specified action and wait up to the specified timeout for it to complete. Return the output of the action if it completes on time or an error otherwise.

Types

type Done

type Done struct {
	// contains filtered or unexported fields
}

func DoInBackgroundUntilStopped

func DoInBackgroundUntilStopped(t *testing.T, actionDescription string, sleepBetweenRepeats time.Duration, action func()) Done

Run the specified action in the background (in a goroutine) repeatedly, waiting the specified amount of time between repetitions. To stop this action, call the Done() function on the returned value.

func (Done) Done

func (done Done) Done()

type Either

type Either struct {
	Result string
	Error  error
}

type FatalError

type FatalError struct {
	Underlying error
}

Marker interface for errors that should not be retried

func (FatalError) Error

func (err FatalError) Error() string

type MaxRetriesExceeded

type MaxRetriesExceeded struct {
	Description string
	MaxRetries  int
}

func (MaxRetriesExceeded) Error

func (err MaxRetriesExceeded) Error() string

type TimeoutExceeded

type TimeoutExceeded struct {
	Description string
	Timeout     time.Duration
}

func (TimeoutExceeded) Error

func (err TimeoutExceeded) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL