Struct: retry.Standard

import "../ibm-cos-sdk-go-v2/aws/retry"

Overview

Standard is the standard retry pattern for the SDK. It uses a set of retryable checks to determine of the failed attempt should be retried, and what retry delay should be used.

Implemented Interfaces

types.AnalyticsFilter, v4.HTTPPresigner, s3.HTTPPresignerV4, retry.IsErrorRetryable, types.MetricsFilter, s3.PresignPost, aws.RetryerV2, arn.S3ObjectLambdaARN, types.SelectObjectContentEventStream

Method Summary collapse

Method Details

func (s *Standard) GetAttemptToken(context.Context) (func(error) error, error)

GetAttemptToken returns the token to be released after then attempt completes. The release token will add NoRetryIncrement to the RateLimiter token pool if the attempt was successful. If the attempt failed, nothing will be done.



222
223
224
// File 'aws/retry/standard.go', line 222

func (s *Standard) GetAttemptToken(context.Context) (func(error) error, error) { return s.GetInitialToken(), nil }

func (s *Standard) GetInitialToken() func(error) error

GetInitialToken returns a token for adding the NoRetryIncrement to the RateLimiter token if the attempt completed successfully without error.

InitialToken applies to result of the each attempt, including the first. Whereas the RetryToken applies to the result of subsequent attempts.

Deprecated: use GetAttemptToken instead.



233
234
235
// File 'aws/retry/standard.go', line 233

func (s *Standard) GetInitialToken() func(error) error { return releaseToken(s.noRetryIncrement).release }

func (s *Standard) GetRetryToken(ctx context.Context, opErr error) (func(error) error, error)

GetRetryToken attempts to deduct the retry cost from the retry token pool. Returning the token release function, or error.



243
244
245
246
247
248
249
250
251
252
253
254
255
256
// File 'aws/retry/standard.go', line 243

func (s *Standard) GetRetryToken(ctx context.Context, opErr error) (func(error) error, error) { cost := s.options.RetryCost if s.timeout.IsErrorTimeout(opErr).Bool() { cost = s.options.RetryTimeoutCost } fn, err := s.options.RateLimiter.GetToken(ctx, cost) if err != nil { return nil, fmt.Errorf("failed to get rate limit token, %w", err) } return releaseToken(fn).release, nil }

func (s *Standard) IsErrorRetryable(err error) bool

IsErrorRetryable returns if the error is can be retried or not. Should not consider the number of attempts made.



210
211
212
// File 'aws/retry/standard.go', line 210

func (s *Standard) IsErrorRetryable(err error) bool { return s.retryable.IsErrorRetryable(err).Bool() }

func (s *Standard) MaxAttempts() int

MaxAttempts returns the maximum number of attempts that can be made for a request before failing.



204
205
206
// File 'aws/retry/standard.go', line 204

func (s *Standard) MaxAttempts() int { return s.options.MaxAttempts }

func (s *Standard) RetryDelay(attempt int, err error) (time.Duration, error)

RetryDelay returns the delay to use before another request attempt is made.



215
216
217
// File 'aws/retry/standard.go', line 215

func (s *Standard) RetryDelay(attempt int, err error) (time.Duration, error) { return s.backoff.BackoffDelay(attempt, err) }