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

fix: update grpc config for retry #230

Merged
merged 2 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>7.0.0</version>
<version>7.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,15 @@ public final UnaryCallable<ExportAgentRequest, Operation> exportAgentCallable()
* Restores the specified agent from a ZIP file.
*
* <p>Replaces the current agent version with a new one. All the intents and entity types in the
* older version are deleted.
* older version are deleted. After the restore, the restored draft agent will be trained
* automatically (unless disabled in agent settings). However, once the restore is done, training
* may not be completed yet. Please call
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
* returns in order to train explicitly.
*
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
* which tracks when restoring is complete. It only tracks when the draft agent is updated not
* when it is done training.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -793,9 +799,15 @@ public final OperationFuture<Empty, Struct> restoreAgentAsync(RestoreAgentReques
* Restores the specified agent from a ZIP file.
*
* <p>Replaces the current agent version with a new one. All the intents and entity types in the
* older version are deleted.
* older version are deleted. After the restore, the restored draft agent will be trained
* automatically (unless disabled in agent settings). However, once the restore is done, training
* may not be completed yet. Please call
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
* returns in order to train explicitly.
*
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
* which tracks when restoring is complete. It only tracks when the draft agent is updated not
* when it is done training.
*
* <p>Sample code:
*
Expand All @@ -822,9 +834,15 @@ public final OperationFuture<Empty, Struct> restoreAgentAsync(RestoreAgentReques
* Restores the specified agent from a ZIP file.
*
* <p>Replaces the current agent version with a new one. All the intents and entity types in the
* older version are deleted.
* older version are deleted. After the restore, the restored draft agent will be trained
* automatically (unless disabled in agent settings). However, once the restore is done, training
* may not be completed yet. Please call
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
* returns in order to train explicitly.
*
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
* which tracks when restoring is complete. It only tracks when the draft agent is updated not
* when it is done training.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -939,9 +957,16 @@ public final UnaryCallable<GetAgentRequest, Agent> getAgentCallable() {
* Imports the specified agent from a ZIP file.
*
* <p>Uploads new intents and entity types without deleting the existing ones. Intents and entity
* types with the same name are replaced with the new versions from ImportAgentRequest.
* types with the same name are replaced with the new versions from
* [ImportAgentRequest][google.cloud.dialogflow.v2.ImportAgentRequest]. After the import, the
* imported draft agent will be trained automatically (unless disabled in agent settings).
* However, once the import is done, training may not be completed yet. Please call
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
* returns in order to train explicitly.
*
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
* which tracks when importing is complete. It only tracks when the draft agent is updated not
* when it is done training.
*
* <p>Sample code:
*
Expand Down Expand Up @@ -969,9 +994,16 @@ public final OperationFuture<Empty, Struct> importAgentAsync(ImportAgentRequest
* Imports the specified agent from a ZIP file.
*
* <p>Uploads new intents and entity types without deleting the existing ones. Intents and entity
* types with the same name are replaced with the new versions from ImportAgentRequest.
* types with the same name are replaced with the new versions from
* [ImportAgentRequest][google.cloud.dialogflow.v2.ImportAgentRequest]. After the import, the
* imported draft agent will be trained automatically (unless disabled in agent settings).
* However, once the import is done, training may not be completed yet. Please call
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
* returns in order to train explicitly.
*
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
* which tracks when importing is complete. It only tracks when the draft agent is updated not
* when it is done training.
*
* <p>Sample code:
*
Expand All @@ -997,9 +1029,16 @@ public final OperationCallable<ImportAgentRequest, Empty, Struct> importAgentOpe
* Imports the specified agent from a ZIP file.
*
* <p>Uploads new intents and entity types without deleting the existing ones. Intents and entity
* types with the same name are replaced with the new versions from ImportAgentRequest.
*
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt;
* types with the same name are replaced with the new versions from
* [ImportAgentRequest][google.cloud.dialogflow.v2.ImportAgentRequest]. After the import, the
* imported draft agent will be trained automatically (unless disabled in agent settings).
* However, once the import is done, training may not be completed yet. Please call
* [TrainAgent][google.cloud.dialogflow.v2.Agents.TrainAgent] and wait for the operation it
* returns in order to train explicitly.
*
* <p>Operation &lt;response: [google.protobuf.Empty][google.protobuf.Empty]&gt; An operation
* which tracks when importing is complete. It only tracks when the draft agent is updated not
* when it is done training.
*
* <p>Sample code:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,9 @@ public static class Builder extends StubSettings.Builder<AgentsStubSettings, Bui
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"idempotent",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
"retry_policy_1_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand All @@ -387,12 +385,14 @@ public static class Builder extends StubSettings.Builder<AgentsStubSettings, Bui
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(20000L))
.setInitialRpcTimeout(Duration.ofMillis(60000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(20000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setMaxRpcTimeout(Duration.ofMillis(60000L))
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("default", settings);
definitions.put("retry_policy_1_params", settings);
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
definitions.put("no_retry_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand Down Expand Up @@ -457,54 +457,54 @@ private static Builder initDefaults(Builder builder) {

builder
.setAgentSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.deleteAgentSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.searchAgentsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.trainAgentSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.exportAgentSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.restoreAgentSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.getAgentSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.importAgentSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.getValidationResultSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));
builder
.trainAgentOperationSettings()
.setInitialCallSettings(
UnaryCallSettings.<TrainAgentRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
.build())
.setResponseTransformer(
ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
Expand All @@ -525,8 +525,8 @@ private static Builder initDefaults(Builder builder) {
.exportAgentOperationSettings()
.setInitialCallSettings(
UnaryCallSettings.<ExportAgentRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
.build())
.setResponseTransformer(
ProtoOperationTransformers.ResponseTransformer.create(ExportAgentResponse.class))
Expand All @@ -548,8 +548,8 @@ private static Builder initDefaults(Builder builder) {
.setInitialCallSettings(
UnaryCallSettings
.<RestoreAgentRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
.build())
.setResponseTransformer(
ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
Expand All @@ -570,8 +570,8 @@ private static Builder initDefaults(Builder builder) {
.importAgentOperationSettings()
.setInitialCallSettings(
UnaryCallSettings.<ImportAgentRequest, OperationSnapshot>newUnaryCallSettingsBuilder()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"))
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"))
.build())
.setResponseTransformer(
ProtoOperationTransformers.ResponseTransformer.create(Empty.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,9 @@ public static class Builder extends StubSettings.Builder<ContextsStubSettings, B
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"idempotent",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
"retry_policy_1_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand All @@ -306,12 +304,14 @@ public static class Builder extends StubSettings.Builder<ContextsStubSettings, B
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(20000L))
.setInitialRpcTimeout(Duration.ofMillis(60000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(20000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setMaxRpcTimeout(Duration.ofMillis(60000L))
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("default", settings);
definitions.put("retry_policy_1_params", settings);
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
definitions.put("no_retry_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand Down Expand Up @@ -359,33 +359,33 @@ private static Builder initDefaults(Builder builder) {

builder
.deleteContextSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.deleteAllContextsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.listContextsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.getContextSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.createContextSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

builder
.updateContextSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params"));

return builder;
}
Expand Down
Loading