Documentation
¶
Overview ¶
Package retry contains logic to retry actions with certain conditions.
Index ¶
- func DoWithRetry(t testing.TestingT, actionDescription string, maxRetries int, ...) stringdeprecated
- func DoWithRetryContext(t testing.TestingT, ctx context.Context, actionDescription string, ...) string
- func DoWithRetryContextE(t testing.TestingT, ctx context.Context, actionDescription string, ...) (string, error)
- func DoWithRetryE(t testing.TestingT, actionDescription string, maxRetries int, ...) (string, error)deprecated
- func DoWithRetryInterface(t testing.TestingT, actionDescription string, maxRetries int, ...) anydeprecated
- func DoWithRetryInterfaceContext(t testing.TestingT, ctx context.Context, actionDescription string, ...) any
- func DoWithRetryInterfaceContextE(t testing.TestingT, ctx context.Context, actionDescription string, ...) (any, error)
- func DoWithRetryInterfaceE(t testing.TestingT, actionDescription string, maxRetries int, ...) (any, error)deprecated
- func DoWithRetryableErrors(t testing.TestingT, actionDescription string, ...) stringdeprecated
- func DoWithRetryableErrorsContext(t testing.TestingT, ctx context.Context, actionDescription string, ...) string
- func DoWithRetryableErrorsContextE(t testing.TestingT, ctx context.Context, actionDescription string, ...) (string, error)
- func DoWithRetryableErrorsE(t testing.TestingT, actionDescription string, ...) (string, error)deprecated
- func DoWithTimeout(t testing.TestingT, actionDescription string, timeout time.Duration, ...) stringdeprecated
- func DoWithTimeoutContext(t testing.TestingT, ctx context.Context, actionDescription string, ...) string
- func DoWithTimeoutContextE(t testing.TestingT, ctx context.Context, actionDescription string, ...) (string, error)
- func DoWithTimeoutE(t testing.TestingT, actionDescription string, timeout time.Duration, ...) (string, error)deprecated
- type Done
- type Either
- type FatalError
- type MaxRetriesExceeded
- type TimeoutExceeded
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoWithRetry
deprecated
func DoWithRetry(t testing.TestingT, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) string
DoWithRetry runs the specified action. If it returns a string, return that string. 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.
Deprecated: Use DoWithRetryContext instead.
func DoWithRetryContext ¶ added in v1.0.0
func DoWithRetryContext(t testing.TestingT, ctx context.Context, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) string
DoWithRetryContext runs the specified action. If it returns a string, return that string. 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. The ctx parameter supports cancellation and timeouts.
func DoWithRetryContextE ¶ added in v1.0.0
func DoWithRetryContextE(t testing.TestingT, ctx context.Context, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) (string, error)
DoWithRetryContextE runs the specified action. If it returns a string, return that string. 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. The ctx parameter supports cancellation and timeouts.
func DoWithRetryE
deprecated
func DoWithRetryE(t testing.TestingT, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) (string, error)
DoWithRetryE runs the specified action. If it returns a string, return that string. 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.
Deprecated: Use DoWithRetryContextE instead.
func DoWithRetryInterface
deprecated
added in
v0.30.14
func DoWithRetryInterface(t testing.TestingT, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (any, error)) any
DoWithRetryInterface runs 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.
Deprecated: Use DoWithRetryInterfaceContext instead.
func DoWithRetryInterfaceContext ¶ added in v1.0.0
func DoWithRetryInterfaceContext(t testing.TestingT, ctx context.Context, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (any, error)) any
DoWithRetryInterfaceContext runs 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. The ctx parameter supports cancellation and timeouts.
func DoWithRetryInterfaceContextE ¶ added in v1.0.0
func DoWithRetryInterfaceContextE(t testing.TestingT, ctx context.Context, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (any, error)) (any, error)
DoWithRetryInterfaceContextE runs 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. The ctx parameter supports cancellation and timeouts.
func DoWithRetryInterfaceE
deprecated
added in
v0.30.14
func DoWithRetryInterfaceE(t testing.TestingT, actionDescription string, maxRetries int, sleepBetweenRetries time.Duration, action func() (any, error)) (any, error)
DoWithRetryInterfaceE runs 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.
Deprecated: Use DoWithRetryInterfaceContextE instead.
func DoWithRetryableErrors
deprecated
added in
v0.16.0
func DoWithRetryableErrors(t testing.TestingT, actionDescription string, retryableErrors map[string]string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) string
DoWithRetryableErrors runs the specified action. If it returns a value, return that value. If it returns an error, check if error message or the string output from the action (which is often stdout/stderr from running some command) matches any of the regular expressions in the specified retryableErrors map. If there is a match, sleep for sleepBetweenRetries, and retry the specified action, up to a maximum of maxRetries retries. If there is no match, return that error immediately, wrapped in a FatalError. If maxRetries is exceeded, return a MaxRetriesExceeded error.
Deprecated: Use DoWithRetryableErrorsContext instead.
func DoWithRetryableErrorsContext ¶ added in v1.0.0
func DoWithRetryableErrorsContext(t testing.TestingT, ctx context.Context, actionDescription string, retryableErrors map[string]string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) string
DoWithRetryableErrorsContext runs the specified action. If it returns a value, return that value. If it returns an error, check if error message or the string output from the action (which is often stdout/stderr from running some command) matches any of the regular expressions in the specified retryableErrors map. If there is a match, sleep for sleepBetweenRetries, and retry the specified action, up to a maximum of maxRetries retries. If there is no match, return that error immediately, wrapped in a FatalError. If maxRetries is exceeded, return a MaxRetriesExceeded error. The ctx parameter supports cancellation and timeouts.
func DoWithRetryableErrorsContextE ¶ added in v1.0.0
func DoWithRetryableErrorsContextE(t testing.TestingT, ctx context.Context, actionDescription string, retryableErrors map[string]string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) (string, error)
DoWithRetryableErrorsContextE runs the specified action. If it returns a value, return that value. If it returns an error, check if error message or the string output from the action (which is often stdout/stderr from running some command) matches any of the regular expressions in the specified retryableErrors map. If there is a match, sleep for sleepBetweenRetries, and retry the specified action, up to a maximum of maxRetries retries. If there is no match, return that error immediately, wrapped in a FatalError. If maxRetries is exceeded, return a MaxRetriesExceeded error. The ctx parameter supports cancellation and timeouts.
func DoWithRetryableErrorsE
deprecated
added in
v0.16.0
func DoWithRetryableErrorsE(t testing.TestingT, actionDescription string, retryableErrors map[string]string, maxRetries int, sleepBetweenRetries time.Duration, action func() (string, error)) (string, error)
DoWithRetryableErrorsE runs the specified action. If it returns a value, return that value. If it returns an error, check if error message or the string output from the action (which is often stdout/stderr from running some command) matches any of the regular expressions in the specified retryableErrors map. If there is a match, sleep for sleepBetweenRetries, and retry the specified action, up to a maximum of maxRetries retries. If there is no match, return that error immediately, wrapped in a FatalError. If maxRetries is exceeded, return a MaxRetriesExceeded error.
Deprecated: Use DoWithRetryableErrorsContextE instead.
func DoWithTimeout
deprecated
func DoWithTimeout(t testing.TestingT, actionDescription string, timeout time.Duration, action func() (string, error)) string
DoWithTimeout runs the specified action and waits 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.
Deprecated: Use DoWithTimeoutContext instead.
func DoWithTimeoutContext ¶ added in v1.0.0
func DoWithTimeoutContext(t testing.TestingT, ctx context.Context, actionDescription string, timeout time.Duration, action func() (string, error)) string
DoWithTimeoutContext runs the specified action and waits 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. The ctx parameter supports cancellation and timeouts.
func DoWithTimeoutContextE ¶ added in v1.0.0
func DoWithTimeoutContextE(t testing.TestingT, ctx context.Context, actionDescription string, timeout time.Duration, action func() (string, error)) (string, error)
DoWithTimeoutContextE runs the specified action and waits up to the specified timeout for it to complete. Return the output of the action if it completes on time or an error otherwise. The ctx parameter supports cancellation and timeouts.
func DoWithTimeoutE
deprecated
func DoWithTimeoutE(t testing.TestingT, actionDescription string, timeout time.Duration, action func() (string, error)) (string, error)
DoWithTimeoutE runs the specified action and waits up to the specified timeout for it to complete. Return the output of the action if it completes on time or an error otherwise.
Deprecated: Use DoWithTimeoutContextE instead.
Types ¶
type Done ¶
type Done struct {
// contains filtered or unexported fields
}
Done can be stopped.
func DoInBackgroundUntilStopped
deprecated
func DoInBackgroundUntilStopped(t testing.TestingT, actionDescription string, sleepBetweenRepeats time.Duration, action func()) Done
DoInBackgroundUntilStopped runs 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.
Deprecated: Use DoInBackgroundUntilStoppedContext instead.
func DoInBackgroundUntilStoppedContext ¶ added in v1.0.0
func DoInBackgroundUntilStoppedContext(t testing.TestingT, ctx context.Context, actionDescription string, sleepBetweenRepeats time.Duration, action func()) Done
DoInBackgroundUntilStoppedContext runs the specified action in the background (in a goroutine) repeatedly, waiting the specified amount of time between repetitions. To stop this action, cancel the ctx or call the Done() function on the returned value. The ctx parameter supports cancellation and timeouts.
type FatalError ¶
type FatalError struct {
Underlying error
}
FatalError is a marker interface for errors that should not be retried.
func (FatalError) Error ¶
func (err FatalError) Error() string
type MaxRetriesExceeded ¶
MaxRetriesExceeded is an error that occurs when the maximum amount of retries is exceeded.
func (MaxRetriesExceeded) Error ¶
func (err MaxRetriesExceeded) Error() string
type TimeoutExceeded ¶
TimeoutExceeded is an error that occurs when a timeout is exceeded.
func (TimeoutExceeded) Error ¶
func (err TimeoutExceeded) Error() string