gapic-common 0.3.1 → 0.3.4

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: 0b273a9734d7790746ebdd37a36fe67e7cd8d02d595ef98ece290f1659836c84
4
- data.tar.gz: ecbf4561705eb6dcb260562c452dbb2f13ac803c08ea7b6df17ee811fa010a87
3
+ metadata.gz: 8d577e52554064fdda97228a6570313d8df9cc3d830ca75b0b43bfd1412a1222
4
+ data.tar.gz: 9ec865b1b777f308449320d2813745738af835c5289df0d4783739dac0310f4c
5
5
  SHA512:
6
- metadata.gz: 33dd83d1eafc82dd3fe79340e3780bbffd228e5373cd3f1c5ce28adea3c76896638e54a71e0a95a7de275d654460b1fc719766429f8d533b0849dbee57ccc9a1
7
- data.tar.gz: b0094f935d8109734023d21c97f8d7436d8cc456a5882fe67ce1fc8f32ebf6643438dac8a14a90f7e14e772d0afe15fba31eae46535e9041eb6e6b58965060e1
6
+ metadata.gz: 71599558c7d1e83abfe002213b24c7089179e52c2e68214002293c0d936ca38283fd4f38e790a3c0ec4c77e228ed1e0083d1ca871c1eaaa43ae33cad7a00ff90
7
+ data.tar.gz: d148bf75ff9afed66dd27fd206db1aaaf9627f7ecfd87d0db0abd0090b984e3318e476aa95e719aa580b3dbac7772c5b6856914d66699b54c1dbf2821e37e019
@@ -1,5 +1,17 @@
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
+
3
15
  ### 0.3.1 / 2020-06-19
4
16
 
5
17
  * Fix file permissions
@@ -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.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.3.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-19 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