Skip to content

Commit

Permalink
fix: switch pubsub/v1 retry config to grpc_service_config
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 336174031

Source-Author: Google APIs <noreply@google.com>
Source-Date: Thu Oct 8 15:10:41 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: bf79839b947d8b5c0f55516b963433faf23b54c4
Source-Link: googleapis/googleapis@bf79839
  • Loading branch information
yoshi-automation committed Feb 1, 2021
1 parent fcf8da4 commit 8e1b1c1
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 105 deletions.
Expand Up @@ -572,32 +572,25 @@ public static class Builder extends StubSettings.Builder<PublisherStubSettings,
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"idempotent",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.ABORTED, StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNKNOWN)));
definitions.put(
"non_idempotent2", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put(
"non_idempotent",
"retry_policy_1_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put(
"idempotent2",
"retry_policy_3_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
definitions.put("none", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
StatusCode.Code.UNKNOWN, StatusCode.Code.ABORTED, StatusCode.Code.UNAVAILABLE)));
definitions.put(
"publish",
"retry_policy_2_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.ABORTED,
StatusCode.Code.CANCELLED,
StatusCode.Code.DEADLINE_EXCEEDED,
StatusCode.Code.INTERNAL,
StatusCode.Code.RESOURCE_EXHAUSTED,
StatusCode.Code.UNKNOWN,
StatusCode.Code.UNAVAILABLE,
StatusCode.Code.UNKNOWN)));
StatusCode.Code.DEADLINE_EXCEEDED)));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand All @@ -614,20 +607,33 @@ public static class Builder extends StubSettings.Builder<PublisherStubSettings,
.setInitialRpcTimeout(Duration.ofMillis(60000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(60000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("default", settings);
definitions.put("retry_policy_1_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(5000L))
.setRpcTimeoutMultiplier(1.3)
.setInitialRpcTimeout(Duration.ofMillis(60000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(60000L))
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("retry_policy_3_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(60000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(60000L))
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("messaging", settings);
definitions.put("retry_policy_2_params", settings);
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
definitions.put("no_retry_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand Down Expand Up @@ -696,13 +702,13 @@ private static Builder initDefaults(Builder builder) {

builder
.createTopicSettings()
.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
.updateTopicSettings()
.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
.publishSettings()
Expand All @@ -718,53 +724,53 @@ private static Builder initDefaults(Builder builder) {
.build());
builder
.publishSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("publish"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("messaging"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_2_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_2_params"));

builder
.getTopicSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

builder
.listTopicsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

builder
.listTopicSubscriptionsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

builder
.listTopicSnapshotsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent2"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

builder
.deleteTopicSettings()
.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
.setIamPolicySettings()
.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
.getIamPolicySettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_3_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_3_params"));

builder
.testIamPermissionsSettings()
.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
.detachSubscriptionSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent2"))
.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
Expand Up @@ -490,27 +490,23 @@ public static class Builder extends StubSettings.Builder<SubscriberStubSettings,
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"idempotent",
"retry_policy_4_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.ABORTED, StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNKNOWN)));
StatusCode.Code.DEADLINE_EXCEEDED,
StatusCode.Code.RESOURCE_EXHAUSTED,
StatusCode.Code.ABORTED,
StatusCode.Code.INTERNAL,
StatusCode.Code.UNAVAILABLE)));
definitions.put(
"non_idempotent",
"retry_policy_6_codes",
ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList(StatusCode.Code.UNAVAILABLE)));
definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
definitions.put(
"idempotent2",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
definitions.put(
"streaming_pull",
"retry_policy_5_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.ABORTED,
StatusCode.Code.DEADLINE_EXCEEDED,
StatusCode.Code.INTERNAL,
StatusCode.Code.RESOURCE_EXHAUSTED,
StatusCode.Code.UNAVAILABLE)));
StatusCode.Code.UNKNOWN, StatusCode.Code.ABORTED, StatusCode.Code.UNAVAILABLE)));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand All @@ -527,31 +523,33 @@ public static class Builder extends StubSettings.Builder<SubscriberStubSettings,
.setInitialRpcTimeout(Duration.ofMillis(60000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(60000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("default", settings);
definitions.put("retry_policy_6_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(25000L))
.setInitialRpcTimeout(Duration.ofMillis(900000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(25000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setMaxRpcTimeout(Duration.ofMillis(900000L))
.setTotalTimeout(Duration.ofMillis(900000L))
.build();
definitions.put("messaging", settings);
definitions.put("retry_policy_4_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(600000L))
.setInitialRpcTimeout(Duration.ofMillis(60000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(600000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setMaxRpcTimeout(Duration.ofMillis(60000L))
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("streaming_messaging", settings);
definitions.put("retry_policy_5_params", settings);
settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build();
definitions.put("no_retry_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand Down Expand Up @@ -637,93 +635,93 @@ private static Builder initDefaults(Builder builder) {

builder
.createSubscriptionSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.getSubscriptionSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.updateSubscriptionSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.listSubscriptionsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.deleteSubscriptionSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.getSnapshotSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent2"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.modifyAckDeadlineSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.acknowledgeSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("messaging"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.pullSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("messaging"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.modifyPushConfigSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.listSnapshotsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.createSnapshotSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.updateSnapshotSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.deleteSnapshotSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.seekSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.setIamPolicySettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

builder
.getIamPolicySettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params"));

builder
.testIamPermissionsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_6_codes"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_6_params"));

return builder;
}
Expand Down
4 changes: 2 additions & 2 deletions synth.metadata
Expand Up @@ -11,8 +11,8 @@
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "706053bbfb3f16ef752e513c2898a1f26cdd8e41",
"internalRef": "323803770"
"sha": "bf79839b947d8b5c0f55516b963433faf23b54c4",
"internalRef": "336174031"
}
},
{
Expand Down

0 comments on commit 8e1b1c1

Please sign in to comment.