feat: add full RetrySettings sample code to Settings classes
Fixes #2596 ☕️
Here's what the SpeechSettings c.g.c. snapshot looks like:
I think the changes look good. You probably need to update showcase as well since it's complaining.
Additionally, is there a way to tell what kind of method the RPC is (specifically if it's an LRO RPC or not)? I think it may be beneficial to give the LROs different sample values. But if it's too hard to do that, then we can probably ignore it since it's not important/ not that much benefit.
I think the changes look good. You probably need to update showcase as well since it's complaining.
ahh thank you - updated.
Additionally, is there a way to tell what kind of method the RPC is (specifically if it's an LRO RPC or not)? I think it may be beneficial to give the LROs different sample values. But if it's too hard to do that, then we can probably ignore it since it's not important/ not that much benefit.
I think I can do this - do you have a set of sample Retry values for LROs that I can try to pop in?
Additionally, is there a way to tell what kind of method the RPC is (specifically if it's an LRO RPC or not)? I think it may be beneficial to give the LROs different sample values. But if it's too hard to do that, then we can probably ignore it since it's not important/ not that much benefit.
I think I can do this - do you have a set of sample Retry values for LROs that I can try to pop in?
Let's try with these default values: https://github.com/googleapis/sdk-platform-java/blob/43de5b568dc0bbdaddf2419652e0cb16de77ddb6/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java#L68-L73
For LROs, we only need those settings: https://github.com/googleapis/google-cloud-java/tree/main?tab=readme-ov-file#configuring-lro-timeouts and the rest can be ignored
@lqiu96 I added logic to set different RetrySettings if the methods are LRO, but none of the goldens are using it, as there's currently logic in (AbstractServiceSettingsComposer)[https://github.com/googleapis/sdk-platform-java/blob/main/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceSettingsClassComposer.java#L136] to pick the first unary method as the example method.
I did update the unit tests so you can see what the LRO example would look like, but I'm guessing it would be very unlikely that there is a service that only has LROs.
@lqiu96 I added logic to set different RetrySettings if the methods are LRO, but none of the goldens are using it, as there's currently logic in (
AbstractServiceSettingsComposer)[https://github.com/googleapis/sdk-platform-java/blob/main/gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceSettingsClassComposer.java#L136] to pick the first unary method as the example method.I did update the unit tests so you can see what the LRO example would look like, but I'm guessing it would be very unlikely that there is a service that only has LROs.
What I'm thinking is if we can find an LRO example and add the LRO equivalent of
* EchoStubSettings.Builder echoSettingsBuilder = EchoStubSettings.newBuilder();
* echoSettingsBuilder
* .echoSettings()
* .setRetrySettings(
* echoSettingsBuilder
* .echoSettings()
* .getRetrySettings()
* .toBuilder()
* .setInitialRetryDelayDuration(Duration.ofSeconds(1))
* .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
* .setMaxAttempts(5)
* .setMaxRetryDelayDuration(Duration.ofSeconds(30))
* .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
* .setRetryDelayMultiplier(1.3)
* .setRpcTimeoutMultiplier(1.5)
* .setTotalTimeoutDuration(Duration.ofSeconds(300))
* .build());
* EchoStubSettings echoSettings = echoSettingsBuilder.build();
as an additional sample. I don't know how much additional work it is, but in my mind it looked be fairly simple. Might need a bit of modifications to be something like:
* EchoStubSettings.Builder echoSettingsBuilder = EchoStubSettings.newBuilder();
* echoSettingsBuilder
* .echoSettings()
* .setPollingAlgorithm(...)
from https://github.com/googleapis/google-cloud-java/tree/main?tab=readme-ov-file#configuring-lro-timeouts
If too much work, let's just create an issue and I'm fine with the above.
Here is the summary of possible violations 😱
-
gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/servicesettings/SyncWait.golden:19, tag
goldensample_generated_EchoSettings_Wait_sync -
gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/servicesettings/stub/SyncWait.golden:19, tag
goldensample_generated_EchoStubSettings_Wait_sync
The end of the violation section. All the stuff below is FYI purposes only.
Here is the summary of changes.
You are about to add 10 region tags.
-
gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/servicesettings/SyncWait.golden:19, tag
goldensample_generated_EchoSettings_Wait_sync -
gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/goldens/samples/servicesettings/stub/SyncWait.golden:19, tag
goldensample_generated_EchoStubSettings_Wait_sync -
test/integration/goldens/asset/samples/snippets/generated/main/java/com/google/cloud/asset/v1/assetservicesettings/exportassets/SyncExportAssets.java:19, tag
cloudasset_v1_generated_AssetServiceSettings_ExportAssets_sync -
test/integration/goldens/asset/samples/snippets/generated/main/java/com/google/cloud/asset/v1/stub/assetservicestubsettings/exportassets/SyncExportAssets.java:19, tag
cloudasset_v1_generated_AssetServiceStubSettings_ExportAssets_sync -
test/integration/goldens/compute/samples/snippets/generated/main/java/com/google/cloud/compute/v1small/addressessettings/delete/SyncDelete.java:19, tag
compute_v1small_generated_AddressesSettings_Delete_sync -
test/integration/goldens/compute/samples/snippets/generated/main/java/com/google/cloud/compute/v1small/stub/addressesstubsettings/delete/SyncDelete.java:19, tag
compute_v1small_generated_AddressesStubSettings_Delete_sync -
test/integration/goldens/logging/samples/snippets/generated/main/java/com/google/cloud/logging/v2/configsettings/copylogentries/SyncCopyLogEntries.java:19, tag
logging_v2_generated_ConfigSettings_CopyLogEntries_sync -
test/integration/goldens/logging/samples/snippets/generated/main/java/com/google/cloud/logging/v2/stub/configservicev2stubsettings/copylogentries/SyncCopyLogEntries.java:19, tag
logging_v2_generated_ConfigServiceV2StubSettings_CopyLogEntries_sync -
test/integration/goldens/redis/samples/snippets/generated/main/java/com/google/cloud/redis/v1beta1/cloudredissettings/createinstance/SyncCreateInstance.java:19, tag
redis_v1beta1_generated_CloudRedisSettings_CreateInstance_sync -
test/integration/goldens/redis/samples/snippets/generated/main/java/com/google/cloud/redis/v1beta1/stub/cloudredisstubsettings/createinstance/SyncCreateInstance.java:19, tag
redis_v1beta1_generated_CloudRedisStubSettings_CreateInstance_sync
This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:
- [ ] Refresh this comment
Quality Gate failed for 'gapic-generator-java-root'
Failed conditions
5.1% Duplication on New Code (required ≤ 3%)
Quality Gate passed for 'java_showcase_integration_tests'
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code