gapic-common 0.2.1 → 0.3.4

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: 5a01e3ff5af64e4b311f48d6022fc719720ae2cc98f4d1596445d4739b6169ac
4
- data.tar.gz: dda8e261142a8ee78281e4e972d4dc80fc638cdfb57e7e2ec748fb6db2e0b1bf
3
+ metadata.gz: 8d577e52554064fdda97228a6570313d8df9cc3d830ca75b0b43bfd1412a1222
4
+ data.tar.gz: 9ec865b1b777f308449320d2813745738af835c5289df0d4783739dac0310f4c
5
5
  SHA512:
6
- metadata.gz: ebd7192024fa4bf307fc906c67cef4b598cb9054c8b8983a87bf5349db047e8c2d0c4de8d09e9bda3fca27b7128b24e4183936880e6b8c77f385419ab5f68f33
7
- data.tar.gz: 4128a5daf1da71de8df0bf5cbb714d79322102fddcb99d091141aa7ac3da62c201093402ef3cd54a2fa6f981e95d80d76bdfd47f75fc7dc989fce7ed3de04686
6
+ metadata.gz: 71599558c7d1e83abfe002213b24c7089179e52c2e68214002293c0d936ca38283fd4f38e790a3c0ec4c77e228ed1e0083d1ca871c1eaaa43ae33cad7a00ff90
7
+ data.tar.gz: d148bf75ff9afed66dd27fd206db1aaaf9627f7ecfd87d0db0abd0090b984e3318e476aa95e719aa580b3dbac7772c5b6856914d66699b54c1dbf2821e37e019
@@ -1,5 +1,25 @@
1
1
  # Release History
2
2
 
3
+ ### 0.3.4 / 2020-08-07
4
+
5
+ * Support the :this_channel_is_insecure gRPC pseudo-credential, used by tests and emulators.
6
+
7
+ ### 0.3.3 / 2020-08-05
8
+
9
+ * Retry configs properly handle error name strings.
10
+
11
+ ### 0.3.2 / 2020-07-30
12
+
13
+ * Alias PagedEnumerable#next_page to PagedEnumerable#next_page!
14
+
15
+ ### 0.3.1 / 2020-06-19
16
+
17
+ * Fix file permissions
18
+
19
+ ### 0.3.0 / 2020-06-18
20
+
21
+ * Update the dependency on google-protobuf to 3.12.2
22
+
3
23
  ### 0.2.1 / 2020-06-02
4
24
 
5
25
  * Fix a crash when resetting a config field to nil when it has a parent but no default
@@ -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.1".freeze
17
+ VERSION = "0.3.4".freeze
18
18
  end
19
19
  end
@@ -58,10 +58,11 @@ module Gapic
58
58
  channel_args = Hash channel_args
59
59
  interceptors = Array interceptors
60
60
 
61
- @grpc_stub = if credentials.is_a? GRPC::Core::Channel
61
+ @grpc_stub = case credentials
62
+ when GRPC::Core::Channel
62
63
  grpc_stub_class.new endpoint, nil, channel_override: credentials,
63
64
  interceptors: interceptors
64
- elsif credentials.is_a? GRPC::Core::ChannelCredentials
65
+ when GRPC::Core::ChannelCredentials, Symbol
65
66
  grpc_stub_class.new endpoint, credentials, channel_args: channel_args,
66
67
  interceptors: interceptors
67
68
  else
@@ -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.1
4
+ version: 0.3.4
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-06-02 00:00:00.000000000 Z
11
+ date: 2020-08-07 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