Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.

Commit 4447393

Browse files
fix: update grpc config for retry (#230)
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/9c18038c-d1ba-45ab-9ded-a79e3b7a4d1b/targets - [ ] To automatically regenerate this PR, check this box. PiperOrigin-RevId: 317902626 Source-Link: googleapis/googleapis@4e8f114
1 parent 652fd7b commit 4447393

13 files changed

Lines changed: 344 additions & 226 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file
1717
<dependency>
1818
<groupId>com.google.cloud</groupId>
1919
<artifactId>libraries-bom</artifactId>
20-
<version>7.0.0</version>
20+
<version>7.0.1</version>
2121
<type>pom</type>
2222
<scope>import</scope>
2323
</dependency>

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/AgentsClient.java

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,15 @@ public final UnaryCallable<ExportAgentRequest, Operation> exportAgentCallable()
763763
* Restores the specified agent from a ZIP file.
764764
*
765765
* <p>Replaces the current agent version with a new one. All the intents and entity types in the
766-
* older version are deleted.
766+
* older version are deleted. After the restore, the restored draft agent will be trained
767+
* automatically (unless disabled in agent settings). However, once the restore is done, training
768+
* may not be completed yet. Please call
769+
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
770+
* returns in order to train explicitly.
767771
*
768-
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
772+
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
773+
* which tracks when restoring is complete. It only tracks when the draft agent is updated not
774+
* when it is done training.
769775
*
770776
* <p>Sample code:
771777
*
@@ -793,9 +799,15 @@ public final OperationFuture<Empty, Struct> restoreAgentAsync(RestoreAgentReques
793799
* Restores the specified agent from a ZIP file.
794800
*
795801
* <p>Replaces the current agent version with a new one. All the intents and entity types in the
796-
* older version are deleted.
802+
* older version are deleted. After the restore, the restored draft agent will be trained
803+
* automatically (unless disabled in agent settings). However, once the restore is done, training
804+
* may not be completed yet. Please call
805+
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
806+
* returns in order to train explicitly.
797807
*
798-
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
808+
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
809+
* which tracks when restoring is complete. It only tracks when the draft agent is updated not
810+
* when it is done training.
799811
*
800812
* <p>Sample code:
801813
*
@@ -822,9 +834,15 @@ public final OperationFuture<Empty, Struct> restoreAgentAsync(RestoreAgentReques
822834
* Restores the specified agent from a ZIP file.
823835
*
824836
* <p>Replaces the current agent version with a new one. All the intents and entity types in the
825-
* older version are deleted.
837+
* older version are deleted. After the restore, the restored draft agent will be trained
838+
* automatically (unless disabled in agent settings). However, once the restore is done, training
839+
* may not be completed yet. Please call
840+
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
841+
* returns in order to train explicitly.
826842
*
827-
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
843+
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
844+
* which tracks when restoring is complete. It only tracks when the draft agent is updated not
845+
* when it is done training.
828846
*
829847
* <p>Sample code:
830848
*
@@ -939,9 +957,16 @@ public final UnaryCallable<GetAgentRequest, Agent> getAgentCallable() {
939957
* Imports the specified agent from a ZIP file.
940958
*
941959
* <p>Uploads new intents and entity types without deleting the existing ones. Intents and entity
942-
* types with the same name are replaced with the new versions from ImportAgentRequest.
960+
* types with the same name are replaced with the new versions from
961+
* [ImportAgentRequest][google.cloud.dialogflow.v2.ImportAgentRequest]. After the import, the
962+
* imported draft agent will be trained automatically (unless disabled in agent settings).
963+
* However, once the import is done, training may not be completed yet. Please call
964+
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
965+
* returns in order to train explicitly.
943966
*
944-
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
967+
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
968+
* which tracks when importing is complete. It only tracks when the draft agent is updated not
969+
* when it is done training.
945970
*
946971
* <p>Sample code:
947972
*
@@ -969,9 +994,16 @@ public final OperationFuture<Empty, Struct> importAgentAsync(ImportAgentRequest
969994
* Imports the specified agent from a ZIP file.
970995
*
971996
* <p>Uploads new intents and entity types without deleting the existing ones. Intents and entity
972-
* types with the same name are replaced with the new versions from ImportAgentRequest.
997+
* types with the same name are replaced with the new versions from
998+
* [ImportAgentRequest][google.cloud.dialogflow.v2.ImportAgentRequest]. After the import, the
999+
* imported draft agent will be trained automatically (unless disabled in agent settings).
1000+
* However, once the import is done, training may not be completed yet. Please call
1001+
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
1002+
* returns in order to train explicitly.
9731003
*
974-
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
1004+
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
1005+
* which tracks when importing is complete. It only tracks when the draft agent is updated not
1006+
* when it is done training.
9751007
*
9761008
* <p>Sample code:
9771009
*
@@ -997,9 +1029,16 @@ public final OperationCallable<ImportAgentRequest, Empty, Struct> importAgentOpe
9971029
* Imports the specified agent from a ZIP file.
9981030
*
9991031
* <p>Uploads new intents and entity types without deleting the existing ones. Intents and entity
1000-
* types with the same name are replaced with the new versions from ImportAgentRequest.
1001-
*
1002-
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
1032+
* types with the same name are replaced with the new versions from
1033+
* [ImportAgentRequest][google.cloud.dialogflow.v2.ImportAgentRequest]. After the import, the
1034+
* imported draft agent will be trained automatically (unless disabled in agent settings).
1035+
* However, once the import is done, training may not be completed yet. Please call
1036+
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
1037+
* returns in order to train explicitly.
1038+
*
1039+
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
1040+
* which tracks when importing is complete. It only tracks when the draft agent is updated not
1041+
* when it is done training.
10031042
*
10041043
* <p>Sample code:
10051044
*

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/AgentsStubSettings.java

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,9 @@ public static class Builder extends StubSettings.Builder<AgentsStubSettings, Bui
369369
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
370370
ImmutableMap.builder();
371371
definitions.put(
372-
"idempotent",
373-
ImmutableSet.copyOf(
374-
Lists.<StatusCode.Code>newArrayList(
375-
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
376-
definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
372+
"retry_policy_1_codes",
373+
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
374+
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
377375
RETRYABLE_CODE_DEFINITIONS = definitions.build();
378376
}
379377

@@ -387,12 +385,14 @@ public static class Builder extends StubSettings.Builder<AgentsStubSettings, Bui
387385
.setInitialRetryDelay(Duration.ofMillis(100L))
388386
.setRetryDelayMultiplier(1.3)
389387
.setMaxRetryDelay(Duration.ofMillis(60000L))
390-
.setInitialRpcTimeout(Duration.ofMillis(20000L))
388+
.setInitialRpcTimeout(Duration.ofMillis(60000L))
391389
.setRpcTimeoutMultiplier(1.0)
392-
.setMaxRpcTimeout(Duration.ofMillis(20000L))
393-
.setTotalTimeout(Duration.ofMillis(600000L))
390+
.setMaxRpcTimeout(Duration.ofMillis(60000L))
391+
.setTotalTimeout(Duration.ofMillis(60000L))
394392
.build();
395-
definitions.put("default", settings);
393+
definitions.put("retry_policy_1_params", settings);
394+
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
395+
definitions.put("no_retry_params", settings);
396396
RETRY_PARAM_DEFINITIONS = definitions.build();
397397
}
398398

@@ -457,54 +457,54 @@ private static Builder initDefaults(Builder builder) {
457457

458458
builder
459459
.setAgentSettings()
460-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
461-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
460+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
461+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
462462

463463
builder
464464
.deleteAgentSettings()
465-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
466-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
465+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
466+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
467467

468468
builder
469469
.searchAgentsSettings()
470-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
471-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
470+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
471+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
472472

473473
builder
474474
.trainAgentSettings()
475-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
476-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
475+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
476+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
477477

478478
builder
479479
.exportAgentSettings()
480-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
481-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
480+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
481+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
482482

483483
builder
484484
.restoreAgentSettings()
485-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
486-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
485+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
486+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
487487

488488
builder
489489
.getAgentSettings()
490-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
491-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
490+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
491+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
492492

493493
builder
494494
.importAgentSettings()
495-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
496-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
495+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
496+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
497497

498498
builder
499499
.getValidationResultSettings()
500-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
501-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
500+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
501+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
502502
builder
503503
.trainAgentOperationSettings()
504504
.setInitialCallSettings(
505505
UnaryCallSettings.<TrainAgentRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
506-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
507-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
506+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
507+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
508508
.build())
509509
.setResponseTransformer(
510510
ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
@@ -525,8 +525,8 @@ private static Builder initDefaults(Builder builder) {
525525
.exportAgentOperationSettings()
526526
.setInitialCallSettings(
527527
UnaryCallSettings.<ExportAgentRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
528-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
529-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
528+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
529+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
530530
.build())
531531
.setResponseTransformer(
532532
ProtoOperationTransformers.ResponseTransformer.create(ExportAgentResponse.class))
@@ -548,8 +548,8 @@ private static Builder initDefaults(Builder builder) {
548548
.setInitialCallSettings(
549549
UnaryCallSettings
550550
.<RestoreAgentRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
551-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
552-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
551+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
552+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
553553
.build())
554554
.setResponseTransformer(
555555
ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
@@ -570,8 +570,8 @@ private static Builder initDefaults(Builder builder) {
570570
.importAgentOperationSettings()
571571
.setInitialCallSettings(
572572
UnaryCallSettings.<ImportAgentRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
573-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
574-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
573+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
574+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
575575
.build())
576576
.setResponseTransformer(
577577
ProtoOperationTransformers.ResponseTransformer.create(Empty.class))

google-cloud-dialogflow/src/main/java/com/google/cloud/dialogflow/v2/stub/ContextsStubSettings.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,9 @@ public static class Builder extends StubSettings.Builder<ContextsStubSettings, B
288288
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
289289
ImmutableMap.builder();
290290
definitions.put(
291-
"idempotent",
292-
ImmutableSet.copyOf(
293-
Lists.<StatusCode.Code>newArrayList(
294-
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
295-
definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
291+
"retry_policy_1_codes",
292+
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
293+
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
296294
RETRYABLE_CODE_DEFINITIONS = definitions.build();
297295
}
298296

@@ -306,12 +304,14 @@ public static class Builder extends StubSettings.Builder<ContextsStubSettings, B
306304
.setInitialRetryDelay(Duration.ofMillis(100L))
307305
.setRetryDelayMultiplier(1.3)
308306
.setMaxRetryDelay(Duration.ofMillis(60000L))
309-
.setInitialRpcTimeout(Duration.ofMillis(20000L))
307+
.setInitialRpcTimeout(Duration.ofMillis(60000L))
310308
.setRpcTimeoutMultiplier(1.0)
311-
.setMaxRpcTimeout(Duration.ofMillis(20000L))
312-
.setTotalTimeout(Duration.ofMillis(600000L))
309+
.setMaxRpcTimeout(Duration.ofMillis(60000L))
310+
.setTotalTimeout(Duration.ofMillis(60000L))
313311
.build();
314-
definitions.put("default", settings);
312+
definitions.put("retry_policy_1_params", settings);
313+
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
314+
definitions.put("no_retry_params", settings);
315315
RETRY_PARAM_DEFINITIONS = definitions.build();
316316
}
317317

@@ -359,33 +359,33 @@ private static Builder initDefaults(Builder builder) {
359359

360360
builder
361361
.deleteContextSettings()
362-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
363-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
362+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
363+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
364364

365365
builder
366366
.deleteAllContextsSettings()
367-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
368-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
367+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
368+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
369369

370370
builder
371371
.listContextsSettings()
372-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
373-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
372+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
373+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
374374

375375
builder
376376
.getContextSettings()
377-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
378-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
377+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
378+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
379379

380380
builder
381381
.createContextSettings()
382-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
383-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
382+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
383+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
384384

385385
builder
386386
.updateContextSettings()
387-
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
388-
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
387+
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
388+
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
389389

390390
return builder;
391391
}

0 commit comments

Comments
 (0)