Documentation
¶
Index ¶
- Variables
- func AssertFirstValueResult[T any](a []T) (*T, error)
- func AssertMaybeSingleValueResult[T any](a []T) (option.Option[T], error)
- func AssertSingleValueResult[T any](a []T, fs ...foundFunc[T]) (*T, error)
- func AssertSingleValueResultIterErr[T any](i iter.Seq2[T, error]) (*T, error)
- func NewEmptyResultError(lastRequest any) error
- func NewTooManyResultsError(count int, lastRequest any) error
- func Retry(ctx context.Context, timeout time.Duration, ...) error
- func RetryUntilEqual[T comparable](ctx context.Context, timeout time.Duration, target T, ...) (T, error)
- func RetryUntilNotFound(ctx context.Context, timeout time.Duration, ...) (any, error)
- func RetryWhen[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), ...) (T, error)
- func RetryWhenAWSErrCodeContains[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), ...) (T, error)
- func RetryWhenAWSErrCodeEquals[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), ...) (T, error)
- func RetryWhenAWSErrMessageContains[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), ...) (T, error)
- func RetryWhenIsA[T any, E error](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error)) (T, error)
- func RetryWhenIsAErrorMessageContains[T any, E errs.ErrorWithErrorMessage](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), ...) (T, error)
- func RetryWhenIsOneOf2[T any, E1, E2 error](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error)) (T, error)
- func RetryWhenIsOneOf3[T any, E1, E2, E3 error](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error)) (T, error)
- func RetryWhenIsOneOf4[T any, E1, E2, E3, E4 error](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error)) (T, error)
- func RetryWhenNewResourceNotFound[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), ...) (T, error)
- func RetryWhenNotFound[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error)) (T, error)
- func SingularDataSourceFindError(resourceType string, err error) error
- func WaitUntil(ctx context.Context, timeout time.Duration, ...) error
- type EmptyResultError
- type Options
- type OptionsFunc
- func WithContinuousTargetOccurence(continuousTargetOccurence int) OptionsFunc
- func WithDelay(delay time.Duration) OptionsFunc
- func WithDelayRand(delayRand time.Duration) OptionsFunc
- func WithMinPollInterval(minPollInterval time.Duration) OptionsFunc
- func WithNotFoundChecks(notFoundChecks int) OptionsFunc
- func WithPollInterval(pollInterval time.Duration) OptionsFunc
- type RetryError
- type Retryable
- type TooManyResultsError
- type WaitOpts
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyResult = &EmptyResultError{}
var ErrFoundResource = retry.ErrFoundResource
var ErrTooManyResults = &TooManyResultsError{}
var NotFound = retry.NotFound
NotFound returns true if the error represents a "resource not found" condition. Specifically, NotFound returns true if the error or a wrapped error is of type retry.NotFoundError.
Deprecated: NotFound is an alias to a function of the same name in internal/retry which handles both Plugin SDK V2 and internal error types. For net-new usage, prefer calling retry.NotFound directly.
var SetLastError = retry.SetLastError
SetLastError sets the LastError field on the error if supported. If lastErr is nil it is ignored.
Deprecated: SetLastError is an alias to a function of the same name in internal/retry which handles both Plugin SDK V2 and internal error types. For net-new usage, prefer calling retry.SetLastError directly.
var TimedOut = retry.TimedOut
TimedOut returns true if the error represents a "wait timed out" condition. Specifically, TimedOut returns true if the error matches all these conditions:
- err is of type retry.TimeoutError
- TimeoutError.LastError is nil
Deprecated: TimedOut is an alias to a function of the same name in internal/retry which handles both Plugin SDK V2 and internal error types. For net-new usage, prefer calling retry.TimedOut directly.
Functions ¶
func AssertFirstValueResult ¶
AssertFirstValueResult returns a pointer to the first value in the specified slice of values. Returns a `NotFound` error otherwise.
func AssertMaybeSingleValueResult ¶
AssertMaybeSingleValueResult returns the single non-nil value in the specified slice, or `None` if the slice is empty. Returns a `NotFound` error otherwise.
func AssertSingleValueResult ¶
AssertSingleValueResult returns a pointer to the single value in the specified slice of values. Returns a `NotFound` error otherwise.
func AssertSingleValueResultIterErr ¶
AssertSingleValueResultIterErr returns either a pointer to the single value in the iterator or the error value from the iterator. If there are not exactly one value, returns a `NotFound` error.
func NewEmptyResultError ¶
func NewTooManyResultsError ¶
func Retry ¶
func Retry(ctx context.Context, timeout time.Duration, f func(context.Context) *RetryError, optFns ...OptionsFunc) error
Retry allows configuration of StateChangeConf's various time arguments. This is especially useful for AWS services that are prone to throttling, such as Route53, where the default durations cause problems.
func RetryUntilEqual ¶
func RetryUntilEqual[T comparable](ctx context.Context, timeout time.Duration, target T, f func(context.Context) (T, error), opts ...backoff.Option) (T, error)
RetryUntilEqual retries the specified function until it returns a value equal to `target`.
func RetryUntilNotFound ¶
func RetryUntilNotFound(ctx context.Context, timeout time.Duration, f func(context.Context) (any, error)) (any, error)
RetryUntilNotFound retries the specified function until it returns a retry.NotFoundError.
func RetryWhen ¶
func RetryWhen[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), retryable Retryable) (T, error)
RetryWhen retries the function `f` when the error it returns satisfies `retryable`. `f` is retried until `timeout` expires.
func RetryWhenAWSErrCodeContains ¶
func RetryWhenAWSErrCodeContains[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), code string) (T, error)
RetryWhenAWSErrCodeContains retries the specified function when it returns an AWS error containing the specified code.
func RetryWhenAWSErrCodeEquals ¶
func RetryWhenAWSErrCodeEquals[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), codes ...string) (T, error)
RetryWhenAWSErrCodeEquals retries the specified function when it returns one of the specified AWS error codes.
func RetryWhenAWSErrMessageContains ¶
func RetryWhenAWSErrMessageContains[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), code, message string) (T, error)
RetryWhenAWSErrMessageContains retries the specified function when it returns an AWS error containing the specified message.
func RetryWhenIsA ¶
func RetryWhenIsOneOf2 ¶
func RetryWhenIsOneOf3 ¶
func RetryWhenIsOneOf4 ¶
func RetryWhenNewResourceNotFound ¶
func RetryWhenNewResourceNotFound[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error), isNewResource bool) (T, error)
RetryWhenNewResourceNotFound retries the specified function when it returns a retry.NotFoundError and `isNewResource` is true.
func RetryWhenNotFound ¶
func RetryWhenNotFound[T any](ctx context.Context, timeout time.Duration, f func(context.Context) (T, error)) (T, error)
RetryWhenNotFound retries the specified function when it returns a retry.NotFoundError.
func SingularDataSourceFindError ¶
SingularDataSourceFindError returns a standard error message for a singular data source's non-nil resource find error.
func WaitUntil ¶
func WaitUntil(ctx context.Context, timeout time.Duration, f func(context.Context) (bool, error), opts WaitOpts) error
WaitUntil waits for the function `f` to return `true`. If `f` returns an error, return immediately with that error. If `timeout` is exceeded before `f` returns `true`, return an error. Waits between calls to `f` using exponential backoff.
Types ¶
type EmptyResultError ¶
type EmptyResultError struct {
LastRequest any
}
func (*EmptyResultError) As ¶
func (e *EmptyResultError) As(target any) bool
func (*EmptyResultError) Error ¶
func (e *EmptyResultError) Error() string
func (*EmptyResultError) Is ¶
func (e *EmptyResultError) Is(err error) bool
type Options ¶
type Options struct {
Delay time.Duration // Wait this time before starting checks
MinPollInterval time.Duration // Smallest time to wait before refreshes (MinTimeout in retry.StateChangeConf)
PollInterval time.Duration // Override MinPollInterval/backoff and only poll this often
NotFoundChecks int // Number of times to allow not found (nil result from Refresh)
ContinuousTargetOccurence int // Number of times the Target state has to occur continuously
}
func (Options) Apply ¶
func (o Options) Apply(c *retry.StateChangeConf)
type OptionsFunc ¶
type OptionsFunc func(*Options)
func WithContinuousTargetOccurence ¶
func WithContinuousTargetOccurence(continuousTargetOccurence int) OptionsFunc
func WithDelay ¶
func WithDelay(delay time.Duration) OptionsFunc
func WithDelayRand ¶
func WithDelayRand(delayRand time.Duration) OptionsFunc
WithDelayRand sets the delay to a value between 0s and the passed duration
func WithMinPollInterval ¶
func WithMinPollInterval(minPollInterval time.Duration) OptionsFunc
func WithNotFoundChecks ¶
func WithNotFoundChecks(notFoundChecks int) OptionsFunc
func WithPollInterval ¶
func WithPollInterval(pollInterval time.Duration) OptionsFunc
type RetryError ¶
type RetryError struct {
// contains filtered or unexported fields
}
RetryError forces client code to choose whether or not a given error is retryable.
func NonRetryableError ¶
func NonRetryableError(err error) *RetryError
NonRetryableError is a helper to create a RetryError that's _not_ retryable from a given error. To prevent logic errors, will return an error when passed a nil error.
func RetryableError ¶
func RetryableError(err error) *RetryError
RetryableError is a helper to create a RetryError that's retryable from a given error. To prevent logic errors, will return an error when passed a nil error.
func (*RetryError) Error ¶
func (e *RetryError) Error() string
func (*RetryError) Unwrap ¶
func (e *RetryError) Unwrap() error
type Retryable ¶
Retryable is a function that is used to decide if a function's error is retryable or not. The error argument can be `nil`. If the error is retryable, returns a bool value of `true` and an error (not necessarily the error passed as the argument). If the error is not retryable, returns a bool value of `false` and either no error (success state) or an error (not necessarily the error passed as the argument).
type TooManyResultsError ¶
func (*TooManyResultsError) As ¶
func (e *TooManyResultsError) As(target any) bool
func (*TooManyResultsError) Error ¶
func (e *TooManyResultsError) Error() string
func (*TooManyResultsError) Is ¶
func (e *TooManyResultsError) Is(err error) bool
type WaitOpts ¶
type WaitOpts struct {
ContinuousTargetOccurence int // Number of times the target state has to occur continuously.
Delay time.Duration // Wait this time before starting checks.
MinTimeout time.Duration // Smallest time to wait before refreshes.
PollInterval time.Duration // Override MinTimeout/backoff and only poll this often.
}