@@ -174,7 +174,7 @@ func GetAwsConfig(ctx context.Context, c *Config) (context.Context, aws.Config,
174174 }
175175 }
176176
177- resolveRetryer (baseCtx , c . TokenBucketRateLimiterCapacity , & awsConfig )
177+ resolveRetryer (baseCtx , c , & awsConfig )
178178
179179 if ! c .SkipCredsValidation {
180180 if _ , _ , err := getAccountIDAndPartitionFromSTSGetCallerIdentity (baseCtx , stsClient (baseCtx , awsConfig , c )); err != nil {
@@ -187,7 +187,7 @@ func GetAwsConfig(ctx context.Context, c *Config) (context.Context, aws.Config,
187187
188188// Adapted from the per-service-client `resolveRetryer()` functions in the AWS SDK for Go v2
189189// e.g. https://github.com/aws/aws-sdk-go-v2/blob/main/service/accessanalyzer/api_client.go
190- func resolveRetryer (ctx context.Context , tokenBucketRateLimiterCapacity int , awsConfig * aws.Config ) {
190+ func resolveRetryer (ctx context.Context , c * Config , awsConfig * aws.Config ) {
191191 retryMode := awsConfig .RetryMode
192192 if len (retryMode ) == 0 {
193193 defaultsMode := resolveDefaultsMode (ctx , awsConfig )
@@ -201,29 +201,31 @@ func resolveRetryer(ctx context.Context, tokenBucketRateLimiterCapacity int, aws
201201 }
202202
203203 var standardOptions []func (* retry.StandardOptions )
204- standardOptions = append (standardOptions , func (so * retry.StandardOptions ) {
205- // AWS SDK for Go v1 DefaultRetryerMaxRetryDelay: https://github.com/aws/aws-sdk-go/blob/9f6e3bb9f523aef97fa1cd5c5f8ba8ecf212e44e/aws/client/default_retryer.go#L48-L49.
206- so .MaxBackoff = 300 * time .Second
207- })
208204
209205 if v , found , _ := awsconfig .GetRetryMaxAttempts (ctx , awsConfig .ConfigSources ); found && v != 0 {
210206 standardOptions = append (standardOptions , func (so * retry.StandardOptions ) {
211207 so .MaxAttempts = v
212208 })
213209 }
214210
215- newRetryer := func (retryMode aws.RetryMode , standardOptions []func (* retry.StandardOptions ), tokenBucketRateLimiterCapacity int ) aws.RetryerV2 {
216- var retryer aws.RetryerV2
211+ if maxBackoff := c .MaxBackoff ; maxBackoff > 0 {
212+ standardOptions = append (standardOptions , func (so * retry.StandardOptions ) {
213+ so .MaxBackoff = maxBackoff
214+ })
215+ }
217216
218- if tokenBucketRateLimiterCapacity > 0 {
219- standardOptions = append (standardOptions , func (so * retry.StandardOptions ) {
220- so .RateLimiter = ratelimit .NewTokenRateLimit (uint (tokenBucketRateLimiterCapacity ))
221- })
222- } else {
223- standardOptions = append (standardOptions , func (so * retry.StandardOptions ) {
224- so .RateLimiter = ratelimit .None
225- })
226- }
217+ if tokenBucketRateLimiterCapacity := c .TokenBucketRateLimiterCapacity ; tokenBucketRateLimiterCapacity > 0 {
218+ standardOptions = append (standardOptions , func (so * retry.StandardOptions ) {
219+ so .RateLimiter = ratelimit .NewTokenRateLimit (uint (tokenBucketRateLimiterCapacity ))
220+ })
221+ } else {
222+ standardOptions = append (standardOptions , func (so * retry.StandardOptions ) {
223+ so .RateLimiter = ratelimit .None
224+ })
225+ }
226+
227+ newRetryer := func (retryMode aws.RetryMode , standardOptions []func (* retry.StandardOptions )) aws.RetryerV2 {
228+ var retryer aws.RetryerV2
227229
228230 switch retryMode {
229231 case aws .RetryModeAdaptive :
@@ -245,7 +247,7 @@ func resolveRetryer(ctx context.Context, tokenBucketRateLimiterCapacity int, aws
245247 awsConfig .Retryer = func () aws.Retryer {
246248 return & networkErrorShortcutter {
247249 // Ensure that each invocation of this function returns an independent Retryer.
248- RetryerV2 : newRetryer (retryMode , slices .Clone (standardOptions ), tokenBucketRateLimiterCapacity ),
250+ RetryerV2 : newRetryer (retryMode , slices .Clone (standardOptions )),
249251 }
250252 }
251253}
0 commit comments