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

docs: Update RetrySettings javadocs to include polling #1863

Merged
merged 6 commits into from
Nov 6, 2023

Conversation

lqiu96
Copy link
Contributor

@lqiu96 lqiu96 commented Jul 18, 2023

Thank you for opening a Pull Request! For general contributing guidelines, please refer to contributing guide

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #2214

@lqiu96 lqiu96 requested a review from blakeli0 July 18, 2023 20:22
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Jul 18, 2023
@sonarqubecloud
Copy link

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarqubecloud
Copy link

[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@sonarqubecloud
Copy link

[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@lqiu96 lqiu96 marked this pull request as ready for review October 31, 2023 14:50
@lqiu96 lqiu96 requested a review from a team as a code owner October 31, 2023 14:50
* Duration.ZERO}.
*
* <p>If there are no configurations, Retries have the default initial retry delay value set above
* and LROs have a default initial poll delay value of {@code Duration.ofMillis(5000)} (5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is the default number coming from? Can we link to where the default number is actually specified? Same comment for all the default numbers below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a reference here:

* <p>In Cloud Client Libraries, Retry and LRO Retry Settings may be configured for each service and
* RPC. These values are set by the service teams and may be found by looking at the
* {Service}StubSettings.java file in each library.
, but it's at the top of the file and may get lost. The default value retry values are populated from the grpc config file and I don't want to link those in here. LROs are preconfigured from the generation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What are the default numbers if there is no gRPC config file? I guess the numbers are coming from constants in GAX ? The concern I have is if we change the default numbers in the future, we would have to change the numbers here as well, and it's very easy to forget to change here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is nothing configured inside the grpc config file, the generator will create a RetrySettings with the default values with values listed above (For example: https://github.com/googleapis/google-cloud-java/blob/8452ac3a8eefa8a9e49ff83187b33be26efe6a01/java-batch/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStubSettings.java#L518). This is what I'll call the RetrySettings default values.

Service teams can modify the grpc config file and that will provide default values for certain callables. These default values is what I'll call the callable default values. This is the RetrySettings which will be configured like: https://github.com/googleapis/google-cloud-java/blob/8452ac3a8eefa8a9e49ff83187b33be26efe6a01/java-batch/google-cloud-batch/src/main/java/com/google/cloud/batch/v1/stub/BatchServiceStubSettings.java#L507-L516

I believe they're both technically default values. The Javadoc I updated only refers the RetrySettings default values since the callable default values differ per service. I can add this explanation in so it's clearer to the readers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The default numbers in RetrySettingsComposer is what I was referring to. If those numbers change, we would have to update the numbers here as well. But since those numbers are in the generator, I don't think it's a good idea to expose the implementation details to Gax either, I think we can leave them as they are for now.

Copy link
Contributor Author

@lqiu96 lqiu96 Nov 6, 2023

Choose a reason for hiding this comment

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

The default numbers in RetrySettingsComposer is what I was referring to. If those numbers change, we would have to update the numbers here as well. But since those numbers are in the generator, I don't think it's a good idea to expose the implementation details to Gax either, I think we can leave them as they are for now.

Yeah, those values are set in the generator (and the generator only sets defaults for LROs). I think if we make an effort to change those, we'll have to remember to update our docs here manually. I'd like for an automated way to do that, but linking to the generator code doesn't seem ideal.

I'll keep as is for now then.

*
* <p>If there are no configurations, Retries have the default max retry delay value set above
* and LROs have a default max poll retry delay value of {@code Duration.ofMillis(45000)} (45
* seconds).
*/
public abstract Builder setMaxRetryDelay(Duration maxDelay);

/**
* MaxAttempts defines the maximum number of attempts to perform. The default value is {@code
* 0}. If this value is greater than 0, and the number of attempts reaches this limit, the logic
Copy link
Collaborator

Choose a reason for hiding this comment

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

I remember that both 0 and 1 mean there is no retry from a YAQS. It's kind of already implied as maxAttempts should include the first attempt, can you please make it clear in the comment here to reduce similar confusion in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Let me know if this makes more sense.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The first attempt will be considered attempt #0. I think this is true if maxAttempts is set to 0, but The first attempt will be considered attempt #1 if maxAttempts is set to 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first attempt will be set as Attempt #0 (

). Every retryAttempt will create the nextAttempt class and update the attemptCount: and the shouldRetry function inside the algorithm will check if it's allowed. In this case, the first retry attempt will be attempt #1 and that will pass this check:
if (maxAttempts > 0 && nextAttemptSettings.getAttemptCount() >= maxAttempts) {
return false;
}
.

I think it would make sense if I specify that maxAttempts refers to the number of retry attempts instead.

Copy link

sonarqubecloud bot commented Nov 1, 2023

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link

sonarqubecloud bot commented Nov 1, 2023

[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@lqiu96 lqiu96 merged commit 3c9cb06 into main Nov 6, 2023
35 checks passed
@lqiu96 lqiu96 deleted the update_retrysettings_javadoc branch November 6, 2023 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gax RetrySettings' documentation should include polling information
2 participants