gapic-generator 0.6.5 → 0.6.6

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: 27e2894595efed8561aa48e9059465257267e7f29310a806251bcc6d4d85c63f
4
- data.tar.gz: af47f16264074317a8d02e73539208a4b43f565ae346aef480619bc73a6b1203
3
+ metadata.gz: 23b2c33b7bbae1c69924aa5c4df7ce43324ba16cee3e581aa353cb4ddf961ec3
4
+ data.tar.gz: ec1125f2cf0614188c1106039c4f562602e3dff6ec574d96d0bca0b5fa904ec2
5
5
  SHA512:
6
- metadata.gz: eacd1840fadb1236cb5ed7efe7ba254a977529435ee7ddff1fcee7bb900fa847ccc0a3b861098f1292a63f72e82f6065146f1f0a0260b0624dc9a184de3d3389
7
- data.tar.gz: 8a93aaef7317b85fc048604b626af4cef13cf90ea2dd785a12180d94d71dbf0bc4ea24a34c828a04825adcfd4ae2b88e4cc3934d41de7de01b3be27f6302aaba
6
+ metadata.gz: bbb0b136b92843f0859bd8f65b8cbf3a64e5d1e52af69aec02975fdb99ab584918152ffd00f71dc1dc4e333bb617a0975228e0f269a357c749e06b2e73b07854
7
+ data.tar.gz: 1b5481f342bc4aef038f5c2cf9fd71fb032192e7c644129f9165b59eec30137d8b75c172b679d36d2edf8740af0ee7fbf458c84a55dd180237122c7eba74461d
@@ -1,5 +1,9 @@
1
1
  # Release History for gapic-generator
2
2
 
3
+ ### 0.6.6 / 2020-08-05
4
+
5
+ * Use numeric error codes rather than strings in generated retry configs.
6
+
3
7
  ### 0.6.5 / 2020-07-16
4
8
 
5
9
  * Examples in auth, rakefile, and readme should pick a non-common service.
@@ -16,6 +16,6 @@
16
16
 
17
17
  module Gapic
18
18
  module Generator
19
- VERSION = "0.6.5"
19
+ VERSION = "0.6.6"
20
20
  end
21
21
  end
@@ -40,6 +40,31 @@ module Gapic
40
40
  MULTIPLIER_JSON_KEY = "backoffMultiplier"
41
41
  STATUS_CODES_JSON_KEY = "retryableStatusCodes"
42
42
 
43
+ # See https://grpc.github.io/grpc/core/md_doc_statuscodes.html for a
44
+ # list of error codes.
45
+ ERROR_CODE_MAPPING = [
46
+ "OK",
47
+ "CANCELLED",
48
+ "UNKNOWN",
49
+ "INVALID_ARGUMENT",
50
+ "DEADLINE_EXCEEDED",
51
+ "NOT_FOUND",
52
+ "ALREADY_EXISTS",
53
+ "PERMISSION_DENIED",
54
+ "RESOURCE_EXHAUSTED",
55
+ "FAILED_PRECONDITION",
56
+ "ABORTED",
57
+ "OUT_OF_RANGE",
58
+ "UNIMPLEMENTED",
59
+ "INTERNAL",
60
+ "UNAVAILABLE",
61
+ "DATA_LOSS",
62
+ "UNAUTHENTICATED"
63
+ ].freeze
64
+
65
+ ERROR_STRING_MAPPING = ERROR_CODE_MAPPING.each_with_index.each_with_object({}) do |(str, num), hash|
66
+ hash[str] = num
67
+ end.freeze
43
68
 
44
69
  ##
45
70
  # Parses ServiceConfig from a json of a GRPC service config
@@ -146,11 +171,26 @@ module Gapic
146
171
  initial_delay_seconds = parse_interval_seconds get(retry_policy_json, INITIAL_DELAY_JSON_KEY)
147
172
  max_delay_seconds = parse_interval_seconds get(retry_policy_json, MAX_DELAY_JSON_KEY)
148
173
  multiplier = get retry_policy_json, MULTIPLIER_JSON_KEY
149
- status_codes = get retry_policy_json, STATUS_CODES_JSON_KEY
174
+ status_codes = convert_codes get retry_policy_json, STATUS_CODES_JSON_KEY
150
175
 
151
176
  RetryPolicy.new initial_delay_seconds, max_delay_seconds, multiplier, status_codes
152
177
  end
153
178
 
179
+ ##
180
+ # Interpret input status codes. Convert strings to their associated integer codes.
181
+ #
182
+ def self.convert_codes input_codes
183
+ return nil if input_codes.nil?
184
+ Array(input_codes).map do |obj|
185
+ case obj
186
+ when String
187
+ ERROR_STRING_MAPPING[obj]
188
+ when Integer
189
+ obj
190
+ end
191
+ end.compact
192
+ end
193
+
154
194
  ##
155
195
  # Parses time expressed in secondds from the GRPC service config json
156
196
  # The time is encoded is a string as float or integer with a letter 's' afterwards
@@ -212,7 +252,7 @@ module Gapic
212
252
  end
213
253
 
214
254
  private_class_method :parse_service_names, :filter_service_method_names, :parse_config,
215
- :parse_retry_policy, :parse_interval_seconds, :valid_float?
255
+ :parse_retry_policy, :parse_interval_seconds, :valid_float?, :convert_codes
216
256
  end
217
257
  end
218
258
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gapic-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernest Landrito
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-07-20 00:00:00.000000000 Z
13
+ date: 2020-08-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionpack