gapic-common 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/gapic/call_options/retry_policy.rb +42 -2
- data/lib/gapic/common/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c05c60537fab8c3e742fe1e802dbc4091c4d990524347a872c79d2e4f6d84d4
|
4
|
+
data.tar.gz: d75c76b1b267d0fe966df22552b9ba9cd4b54442e1738fa7ca8aaa27c1ef4532
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a03d7228866bce04a0a8a0c24b9de11fe16169f3d7fba3af4f84ec87ac5f0766393a37c4d3da88b2e4306275fd6e774290d33f5eda647796a27b0d6b7370d0c5
|
7
|
+
data.tar.gz: 52d78a9002d6c76c25485bb891961981e55cff4f8a103273fcf86dd3800573e870ad0a36871f47326a46c715f32a376705bc7b1ad8672a72d1a3b66466836c39
|
data/CHANGELOG.md
CHANGED
@@ -29,7 +29,7 @@ module Gapic
|
|
29
29
|
# @param max_delay [Numeric] client-side timeout
|
30
30
|
#
|
31
31
|
def initialize retry_codes: nil, initial_delay: nil, multiplier: nil, max_delay: nil
|
32
|
-
@retry_codes = retry_codes
|
32
|
+
@retry_codes = convert_codes retry_codes
|
33
33
|
@initial_delay = initial_delay
|
34
34
|
@multiplier = multiplier
|
35
35
|
@max_delay = max_delay
|
@@ -77,7 +77,7 @@ module Gapic
|
|
77
77
|
def apply_defaults retry_policy
|
78
78
|
return unless retry_policy.is_a? Hash
|
79
79
|
|
80
|
-
@retry_codes ||= retry_policy[:retry_codes]
|
80
|
+
@retry_codes ||= convert_codes retry_policy[:retry_codes]
|
81
81
|
@initial_delay ||= retry_policy[:initial_delay]
|
82
82
|
@multiplier ||= retry_policy[:multiplier]
|
83
83
|
@max_delay ||= retry_policy[:max_delay]
|
@@ -85,6 +85,34 @@ module Gapic
|
|
85
85
|
self
|
86
86
|
end
|
87
87
|
|
88
|
+
# @private
|
89
|
+
# See https://grpc.github.io/grpc/core/md_doc_statuscodes.html for a
|
90
|
+
# list of error codes.
|
91
|
+
ERROR_CODE_MAPPING = [
|
92
|
+
"OK",
|
93
|
+
"CANCELLED",
|
94
|
+
"UNKNOWN",
|
95
|
+
"INVALID_ARGUMENT",
|
96
|
+
"DEADLINE_EXCEEDED",
|
97
|
+
"NOT_FOUND",
|
98
|
+
"ALREADY_EXISTS",
|
99
|
+
"PERMISSION_DENIED",
|
100
|
+
"RESOURCE_EXHAUSTED",
|
101
|
+
"FAILED_PRECONDITION",
|
102
|
+
"ABORTED",
|
103
|
+
"OUT_OF_RANGE",
|
104
|
+
"UNIMPLEMENTED",
|
105
|
+
"INTERNAL",
|
106
|
+
"UNAVAILABLE",
|
107
|
+
"DATA_LOSS",
|
108
|
+
"UNAUTHENTICATED"
|
109
|
+
].freeze
|
110
|
+
|
111
|
+
# @private
|
112
|
+
ERROR_STRING_MAPPING = ERROR_CODE_MAPPING.each_with_index.each_with_object({}) do |(str, num), hash|
|
113
|
+
hash[str] = num
|
114
|
+
end.freeze
|
115
|
+
|
88
116
|
private
|
89
117
|
|
90
118
|
def retry? error
|
@@ -96,6 +124,18 @@ module Gapic
|
|
96
124
|
Kernel.sleep delay
|
97
125
|
end
|
98
126
|
|
127
|
+
def convert_codes input_codes
|
128
|
+
return nil if input_codes.nil?
|
129
|
+
Array(input_codes).map do |obj|
|
130
|
+
case obj
|
131
|
+
when String
|
132
|
+
ERROR_STRING_MAPPING[obj]
|
133
|
+
when Integer
|
134
|
+
obj
|
135
|
+
end
|
136
|
+
end.compact
|
137
|
+
end
|
138
|
+
|
99
139
|
##
|
100
140
|
# Calculate and set the next delay value.
|
101
141
|
def increment_delay!
|
data/lib/gapic/common/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gapic-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google API Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|