Skip to content

Commit

Permalink
Merge pull request #918 from hashicorp/b-shared-retryer
Browse files Browse the repository at this point in the history
Independent `aws-sdk-go-v2` retryers
  • Loading branch information
ewbankkit authored Feb 14, 2024
2 parents b3d417a + 66b8089 commit 3f64c31
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions aws_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,24 +206,29 @@ func resolveRetryer(ctx context.Context, awsConfig *aws.Config) {
})
}

var retryer aws.RetryerV2
switch retryMode {
case aws.RetryModeAdaptive:
var adaptiveOptions []func(*retry.AdaptiveModeOptions)
if len(standardOptions) != 0 {
adaptiveOptions = append(adaptiveOptions, func(ao *retry.AdaptiveModeOptions) {
ao.StandardOptions = append(ao.StandardOptions, standardOptions...)
})
newRetryer := func(retryMode aws.RetryMode, standardOptions []func(*retry.StandardOptions)) aws.RetryerV2 {
var retryer aws.RetryerV2
switch retryMode {
case aws.RetryModeAdaptive:
var adaptiveOptions []func(*retry.AdaptiveModeOptions)
if len(standardOptions) != 0 {
adaptiveOptions = append(adaptiveOptions, func(ao *retry.AdaptiveModeOptions) {
ao.StandardOptions = append(ao.StandardOptions, standardOptions...)
})
}
retryer = retry.NewAdaptiveMode(adaptiveOptions...)

default:
retryer = retry.NewStandard(standardOptions...)
}
retryer = retry.NewAdaptiveMode(adaptiveOptions...)

default:
retryer = retry.NewStandard(standardOptions...)
return retryer
}

awsConfig.Retryer = func() aws.Retryer {
return &networkErrorShortcutter{
RetryerV2: retryer,
// Ensure that each invocation of this function returns an independent Retryer.
RetryerV2: newRetryer(retryMode, standardOptions),
}
}
}
Expand Down

0 comments on commit 3f64c31

Please sign in to comment.