Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sqs client retryer #1099

Merged
merged 2 commits into from
Dec 12, 2024
Merged

Add sqs client retryer #1099

merged 2 commits into from
Dec 12, 2024

Conversation

tiationg-kho
Copy link
Contributor

Issue #, if available:
#717

Description of changes:

  • Add sqs client retryer
  • Add sqs client retryer unit test

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@tiationg-kho tiationg-kho requested a review from a team as a code owner December 11, 2024 01:02
@@ -223,7 +222,7 @@ func main() {
QueueURL: nthConfig.QueueURL,
InterruptionChan: interruptionChan,
CancelChan: cancelChan,
SQS: sqs.New(sess),
SQS: sqsevent.GetSqsClient(sess),
ASG: autoscaling.New(sess),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also add retry for asg client?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could keep use default retryer for asg client.

DefaultRetryer: client.DefaultRetryer{
NumMaxRetries: client.DefaultRetryerMaxNumRetries,
MinRetryDelay: client.DefaultRetryerMinRetryDelay,
MaxRetryDelay: 1200 * time.Millisecond,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any particular reason why we don't set MaxRetryDelay to be DefaultRetryerMaxRetryDelay and same for DefaultRetryerMinThrottleDelay? https://github.com/aws/aws-sdk-go/blob/7112c0a0c2d01713a9db2d57f0e5722225baf5b5/aws/client/default_retryer.go#L49C2-L49C29

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by adding doc comment.

client.DefaultRetryer
}

func (r SqsRetryer) ShouldRetry(req *request.Request) bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: personally I would prefer more descriptive variable names (perhaps retryer instead or r), just so I don't have to search for the type.

temp bool
}

func TestGetSqsClient(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test case seems unnecessary because it's testing an implementation detail rather than behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would keep test case to test custom retryer config is consumed or not.

Copy link
Contributor

@Lu-David Lu-David left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tiationg-kho tiationg-kho merged commit 191b9a7 into aws:main Dec 12, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants