gapic-common 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb1fde9489ba4700abd83cbf1a7fea7aab2ed2f844da5ac2070b8c73fe6bf0d8
4
- data.tar.gz: bf9a3bce0b7d5c31edf806baceb5e228318ea3656a84c2a6e8b00bf11acbeee2
3
+ metadata.gz: 6c05c60537fab8c3e742fe1e802dbc4091c4d990524347a872c79d2e4f6d84d4
4
+ data.tar.gz: d75c76b1b267d0fe966df22552b9ba9cd4b54442e1738fa7ca8aaa27c1ef4532
5
5
  SHA512:
6
- metadata.gz: 281a1e48c10da144d2494e566468849299cf24639ca6119428cea669080c7ff435b758383b2ecf1173edd774c765d69a017f347b1e4ad49373b0c9d2925c2834
7
- data.tar.gz: b33835a789ff87319ccb7ef8c448de8cadd44a8c44cf2c52f9553f7ceeea6d9b4715dcd19a1723cf9085d32b5be69dec0e2a46d39755aff0a795e6b030332339
6
+ metadata.gz: a03d7228866bce04a0a8a0c24b9de11fe16169f3d7fba3af4f84ec87ac5f0766393a37c4d3da88b2e4306275fd6e774290d33f5eda647796a27b0d6b7370d0c5
7
+ data.tar.gz: 52d78a9002d6c76c25485bb891961981e55cff4f8a103273fcf86dd3800573e870ad0a36871f47326a46c715f32a376705bc7b1ad8672a72d1a3b66466836c39
@@ -1,5 +1,9 @@
1
1
  # Release History
2
2
 
3
+ ### 0.3.3 / 2020-08-05
4
+
5
+ * Retry configs properly handle error name strings.
6
+
3
7
  ### 0.3.2 / 2020-07-30
4
8
 
5
9
  * Alias PagedEnumerable#next_page to PagedEnumerable#next_page!
@@ -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!
@@ -14,6 +14,6 @@
14
14
 
15
15
  module Gapic
16
16
  module Common
17
- VERSION = "0.3.2".freeze
17
+ VERSION = "0.3.3".freeze
18
18
  end
19
19
  end
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.2
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-07-30 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf