Struct: retry.AdaptiveMode

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

Overview

AdaptiveMode provides an experimental retry strategy that expands on the Standard retry strategy, adding client attempt rate limits. The attempt rate limit is initially unrestricted, but becomes restricted when the attempt fails with for a throttle error. When restricted AdaptiveMode may need to sleep before an attempt is made, if too many throttles have been received. AdaptiveMode’s sleep can be canceled with context cancel. Set AdaptiveModeOptions FailOnNoAttemptTokens to change the behavior from sleep, to fail fast.

Eventually unrestricted attempt rate limit will be restored once attempts no longer are failing due to throttle errors.

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 (a *AdaptiveMode) GetAttemptToken(ctx context.Context) (func(error) error, error)

GetAttemptToken returns the attempt token that can be used to rate limit attempt calls. Will be used by the SDK’s retry package’s Attempt middleware to get an attempt token prior to calling the temp and releasing the attempt token after the attempt has been made.



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// File 'aws/retry/adaptive.go', line 131

func (a *AdaptiveMode) GetAttemptToken(ctx context.Context) (func(error) error, error) { for { acquiredToken, waitTryAgain := a.rateLimit.AcquireToken(a.options.RequestCost) if acquiredToken { break } if a.options.FailOnNoAttemptTokens { return nil, fmt.Errorf( "unable to get attempt token, and FailOnNoAttemptTokens enables") } if err := sdk.SleepWithContext(ctx, waitTryAgain); err != nil { return nil, fmt.Errorf("failed to wait for token to be available, %w", err) } } return a.handleResponse, nil }

func (a *AdaptiveMode) GetInitialToken() (releaseToken func(error) error)

GetInitialToken returns the initial attempt token that can increment the retry token pool if the attempt is successful.

Deprecated: This method does not provide a way to block using Context, nor can it return an error. Use RetryerV2, and GetAttemptToken instead. Only present to implement Retryer interface.



123
124
125
// File 'aws/retry/adaptive.go', line 123

func (a *AdaptiveMode) GetInitialToken() (releaseToken func(error) error) { return nopRelease }

func (a *AdaptiveMode) IsErrorRetryable(err error) bool

IsErrorRetryable returns if the failed attempt is retryable. This check should determine if the error can be retried, or if the error is terminal.



90
91
92
// File 'aws/retry/adaptive.go', line 90

func (a *AdaptiveMode) IsErrorRetryable(err error) bool { return a.retryer.IsErrorRetryable(err) }

func (a *AdaptiveMode) MaxAttempts() int

MaxAttempts returns the maximum number of attempts that can be made for an attempt before failing. A value of 0 implies that the attempt should be retried until it succeeds if the errors are retryable.



97
98
99
// File 'aws/retry/adaptive.go', line 97

func (a *AdaptiveMode) MaxAttempts() int { return a.retryer.MaxAttempts() }