gapic-common 0.2.1 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/lib/gapic/call_options/retry_policy.rb +42 -2
- data/lib/gapic/common/version.rb +1 -1
- data/lib/gapic/grpc/service_stub.rb +3 -2
- data/lib/gapic/paged_enumerable.rb +1 -0
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d577e52554064fdda97228a6570313d8df9cc3d830ca75b0b43bfd1412a1222
|
4
|
+
data.tar.gz: 9ec865b1b777f308449320d2813745738af835c5289df0d4783739dac0310f4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71599558c7d1e83abfe002213b24c7089179e52c2e68214002293c0d936ca38283fd4f38e790a3c0ec4c77e228ed1e0083d1ca871c1eaaa43ae33cad7a00ff90
|
7
|
+
data.tar.gz: d148bf75ff9afed66dd27fd206db1aaaf9627f7ecfd87d0db0abd0090b984e3318e476aa95e719aa580b3dbac7772c5b6856914d66699b54c1dbf2821e37e019
|
data/CHANGELOG.md
CHANGED
@@ -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!
|
data/lib/gapic/common/version.rb
CHANGED
@@ -58,10 +58,11 @@ module Gapic
|
|
58
58
|
channel_args = Hash channel_args
|
59
59
|
interceptors = Array interceptors
|
60
60
|
|
61
|
-
@grpc_stub =
|
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
|
-
|
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
|
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.
|
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-
|
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.
|
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.
|
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
|