gapic-common 0.2.0 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f3b2d13b4fd64ffb7bf7d92dc1f76dda06c00d1f6a6f7347a8f196e19467dbd
4
- data.tar.gz: 40990944ff16cd31ff46cd708e8efd8d607b958cbbb7dea3ef2e207561a0a5ba
3
+ metadata.gz: 6c05c60537fab8c3e742fe1e802dbc4091c4d990524347a872c79d2e4f6d84d4
4
+ data.tar.gz: d75c76b1b267d0fe966df22552b9ba9cd4b54442e1738fa7ca8aaa27c1ef4532
5
5
  SHA512:
6
- metadata.gz: 60db7a415a89b0fc864eeeef8e377e943c6f669c2ea4ce5c707af8617934f27ead164bf615e9d9dbe68706ce19a218196da2154b2a1c1132e81c2031d15525da
7
- data.tar.gz: 203ee7c2a5245287db6b0b043dc42dfee37d31e47294201540bd5c4a351a5db51131273c58e8ffdcfb196198019e97d26faa336f7cb3aae7698124ef6baaf962
6
+ metadata.gz: a03d7228866bce04a0a8a0c24b9de11fe16169f3d7fba3af4f84ec87ac5f0766393a37c4d3da88b2e4306275fd6e774290d33f5eda647796a27b0d6b7370d0c5
7
+ data.tar.gz: 52d78a9002d6c76c25485bb891961981e55cff4f8a103273fcf86dd3800573e870ad0a36871f47326a46c715f32a376705bc7b1ad8672a72d1a3b66466836c39
@@ -1,5 +1,25 @@
1
1
  # Release History
2
2
 
3
+ ### 0.3.3 / 2020-08-05
4
+
5
+ * Retry configs properly handle error name strings.
6
+
7
+ ### 0.3.2 / 2020-07-30
8
+
9
+ * Alias PagedEnumerable#next_page to PagedEnumerable#next_page!
10
+
11
+ ### 0.3.1 / 2020-06-19
12
+
13
+ * Fix file permissions
14
+
15
+ ### 0.3.0 / 2020-06-18
16
+
17
+ * Update the dependency on google-protobuf to 3.12.2
18
+
19
+ ### 0.2.1 / 2020-06-02
20
+
21
+ * Fix a crash when resetting a config field to nil when it has a parent but no default
22
+
3
23
  ### 0.2.0 / 2020-03-17
4
24
 
5
25
  * Support default call options in Gapic::Operation
@@ -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.2.0".freeze
17
+ VERSION = "0.3.3".freeze
18
18
  end
19
19
  end
@@ -88,7 +88,7 @@ module Gapic
88
88
  valid_value ||= begin
89
89
  # Allow nil if parent config has the getter method.
90
90
  parent = instance_variable_get :@parent_config if instance_variable_defined? :@parent_config
91
- parent&.respond_to? name
91
+ parent&.respond_to? name_setter
92
92
  end
93
93
  end
94
94
  raise ArgumentError unless valid_value
@@ -84,6 +84,7 @@ module Gapic
84
84
  # @param metadata_type [Class] The class type to be unpacked from the metadata. If not provided the class type
85
85
  # will be looked up. Optional.
86
86
  # @param options [Gapic::CallOptions] call options for this operation
87
+ #
87
88
  def initialize grpc_op, client, result_type: nil, metadata_type: nil, options: {}
88
89
  @grpc_op = grpc_op
89
90
  @client = client
@@ -229,7 +230,6 @@ module Gapic
229
230
  else
230
231
  @options.to_h
231
232
  end
232
-
233
233
  options = Gapic::CallOptions.new(**options)
234
234
  gax_op = @client.get_operation({ name: @grpc_op.name }, options)
235
235
  @grpc_op = gax_op.grpc_op
@@ -132,6 +132,7 @@ module Gapic
132
132
  end
133
133
  @page
134
134
  end
135
+ alias next_page next_page!
135
136
 
136
137
  ##
137
138
  # The page token to be used for the next RPC call.
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.2.0
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-03-17 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
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '3.12'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.12.2
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '3.2'
29
+ version: '3.12'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 3.12.2
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: googleapis-common-protos
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -268,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
274
  - !ruby/object:Gem::Version
269
275
  version: '0'
270
276
  requirements: []
271
- rubygems_version: 3.1.2
277
+ rubygems_version: 3.0.3
272
278
  signing_key:
273
279
  specification_version: 4
274
280
  summary: Common code for GAPIC-generated API clients