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

Implement maxAttempts inside the RetrySettings for GAPICs #2306

Open
lqiu96 opened this issue Dec 13, 2023 · 0 comments
Open

Implement maxAttempts inside the RetrySettings for GAPICs #2306

lqiu96 opened this issue Dec 13, 2023 · 0 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@lqiu96
Copy link
Contributor

lqiu96 commented Dec 13, 2023

RetrySettingsComposer doesn't have logic to create set the maxAttempts value:

private static List<Expr> createRetrySettingsExprs(
String settingsName,
GapicRetrySettings settings,
VariableExpr settingsVarExpr,
VariableExpr definitionsVarExpr) {
Expr settingsBuilderExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(FIXED_TYPESTORE.get("RetrySettings"))
.setMethodName("newBuilder")
.build();
RetryPolicy retryPolicy = settings.retryPolicy();
if (settings.kind().equals(GapicRetrySettings.Kind.FULL)) {
Preconditions.checkState(
retryPolicy.hasInitialBackoff(),
String.format("initialBackoff not found for setting %s", settingsName));
settingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(settingsBuilderExpr)
.setMethodName("setInitialRetryDelay")
.setArguments(createDurationOfMillisExpr(toValExpr(retryPolicy.getInitialBackoff())))
.build();
settingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(settingsBuilderExpr)
.setMethodName("setRetryDelayMultiplier")
.setArguments(toValExpr(retryPolicy.getBackoffMultiplier()))
.build();
Preconditions.checkState(
retryPolicy.hasMaxBackoff(),
String.format("maxBackoff not found for setting %s", settingsName));
settingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(settingsBuilderExpr)
.setMethodName("setMaxRetryDelay")
.setArguments(createDurationOfMillisExpr(toValExpr(retryPolicy.getMaxBackoff())))
.build();
}
if (!settings.kind().equals(GapicRetrySettings.Kind.NONE)) {
settingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(settingsBuilderExpr)
.setMethodName("setInitialRpcTimeout")
.setArguments(createDurationOfMillisExpr(toValExpr(settings.timeout())))
.build();
}
// This will always be done, no matter the type of the retry settings object.
settingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(settingsBuilderExpr)
.setMethodName("setRpcTimeoutMultiplier")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.DOUBLE).setValue("1.0").build()))
.build();
if (!settings.kind().equals(GapicRetrySettings.Kind.NONE)) {
for (String setterMethodName : Arrays.asList("setMaxRpcTimeout", "setTotalTimeout")) {
settingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(settingsBuilderExpr)
.setMethodName(setterMethodName)
.setArguments(createDurationOfMillisExpr(toValExpr(settings.timeout())))
.build();
}
}
settingsBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(settingsBuilderExpr)
.setMethodName("build")
.setReturnType(settingsVarExpr.type())
.build();
Expr settingsAssignExpr =
AssignmentExpr.builder()
.setVariableExpr(settingsVarExpr)
.setValueExpr(settingsBuilderExpr)
.build();
Expr definitionsPutExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(definitionsVarExpr)
.setMethodName("put")
.setArguments(
ValueExpr.withValue(StringObjectValue.withValue(settingsName)), settingsVarExpr)
.build();
return Arrays.asList(settingsAssignExpr, definitionsPutExpr);
}
even if it's set in the grpc_service.json file.

Searching through google-cloud-java shows that there aren't any occurrences of setMaxAttempts being generated in the StubSettings: https://github.com/search?q=repo%3Agoogleapis%2Fgoogle-cloud-java%20setMaxAttempts&type=code

@lqiu96 lqiu96 added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p3 Desirable enhancement or fix. May not be included in next release. labels Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

1 participant