Skip to content

Conversation

@HantingZhang2
Copy link
Contributor

What does this PR do?

Adds retry support and corresponding config options.

Additional Notes

Review checklist

Please check relevant items below:

  • This PR includes all newly recorded cassettes for any modified tests.

  • This PR does not rely on API client schema changes.

    • The CI should be fully passing.
  • Or, this PR relies on API schema changes and this is a Draft PR that includes tests.

    • Note: CI shouldn't be run on this Draft PR, as its expected to fail without the corresponding schema changes.

@HantingZhang2 HantingZhang2 requested a review from a team as a code owner August 4, 2023 13:22
@HantingZhang2 HantingZhang2 added the changelog/Added Added features results into a minor version bump label Aug 4, 2023
@HantingZhang2 HantingZhang2 changed the title Hantingz/add retry Add retry support when 429 Aug 8, 2023
@github-actions github-actions bot added the documentation Documentation related changes label Aug 8, 2023
@HantingZhang2 HantingZhang2 changed the title Add retry support when 429 Add retry support when rate limited Aug 8, 2023
@therve therve changed the title Add retry support when rate limited Add retry support Aug 9, 2023
Copy link
Contributor

@therve therve left a comment

Choose a reason for hiding this comment

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

Looks good! 2 other changes I'd like to see:

  • Be able to mock sleep in the test. Maybe add a sleep method on RetryConfig, so that you can override it in tests
  • Add a test for 500

if (statusCode == 429 || statusCode >= 500) {
statusToRetry = true;
}
return (retryConfig.maxRetries >= retryCount && statusToRetry && retryConfig.isEnableRetry());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return (retryConfig.maxRetries >= retryCount && statusToRetry && retryConfig.isEnableRetry());
return (retryConfig.maxRetries > retryCount && statusToRetry && retryConfig.isEnableRetry());

As you start with 0 this should be a strict comparison.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's still true?

README.md Outdated
To enable the client to retry when rate limited (status 429) or status 500 and above:

```java
defaultClient.setRetry(new RetryConfig(true, int <multiplier_for_retry_backoff>, int <base_for_retry_backoff>,int <max_retry_attemps>))
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's document enableRetry here insread.

if (statusCode == 429 || statusCode >= 500) {
statusToRetry = true;
}
return (retryConfig.maxRetries >= retryCount && statusToRetry && retryConfig.isEnableRetry());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's still true?

@HantingZhang2 HantingZhang2 merged commit aeedf94 into master Aug 16, 2023
@HantingZhang2 HantingZhang2 deleted the hantingz/add-retry branch August 16, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/Added Added features results into a minor version bump documentation Documentation related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants