google-gax 0.8.10 → 0.8.12
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 +4 -4
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/lib/google/gax.rb +0 -0
- data/lib/google/gax/api_callable.rb +0 -0
- data/lib/google/gax/bundling.rb +0 -0
- data/lib/google/gax/constants.rb +0 -0
- data/lib/google/gax/credentials.rb +0 -0
- data/lib/google/gax/errors.rb +5 -0
- data/lib/google/gax/grpc.rb +43 -2
- data/lib/google/gax/operation.rb +0 -0
- data/lib/google/gax/path_template.rb +0 -0
- data/lib/google/gax/settings.rb +0 -0
- data/lib/google/gax/util.rb +10 -1
- data/lib/google/gax/version.rb +1 -1
- data/lib/google/gax/version.rb~ +0 -0
- data/lib/google/longrunning/operations_client.rb +0 -0
- data/lib/google/longrunning/operations_client_config.json +0 -0
- data/spec/fixtures/fixture.proto +0 -0
- data/spec/fixtures/fixture_pb.rb +0 -0
- data/spec/google/gax/api_callable_spec.rb +0 -0
- data/spec/google/gax/bundling_spec.rb +0 -0
- data/spec/google/gax/credentials_spec.rb +0 -0
- data/spec/google/gax/grpc_spec.rb +0 -0
- data/spec/google/gax/operation_spec.rb +0 -0
- data/spec/google/gax/path_template_spec.rb +0 -0
- data/spec/google/gax/settings_spec.rb +0 -0
- data/spec/google/gax/util_spec.rb +16 -0
- data/spec/spec_helper.rb +0 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b97f693e0972f255cf0b0ddbbf27a63370afc04
|
4
|
+
data.tar.gz: 852fb0aeeeb4312fae5951bcf4a034466dcb38ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5552ba83b4e65d7889df1fdec4cf3f59d07b96161c5064f7c2344f0eb8299daea86cfddd55e35a1ca01b16dba846d46c34cfe933d15974a0353624862dafc9ca
|
7
|
+
data.tar.gz: 1970759850a9d2ccd7f9655a688b3bf8bbb973442e9ce542dc6b53e21f412c68b3fa0cfe6d20d85f26f06de3e1f552af4ffcd64b659e21235c7f1ca3781a7ad7
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/lib/google/gax.rb
CHANGED
File without changes
|
File without changes
|
data/lib/google/gax/bundling.rb
CHANGED
File without changes
|
data/lib/google/gax/constants.rb
CHANGED
File without changes
|
File without changes
|
data/lib/google/gax/errors.rb
CHANGED
@@ -29,16 +29,21 @@
|
|
29
29
|
|
30
30
|
require 'English'
|
31
31
|
|
32
|
+
require 'google/gax/grpc'
|
33
|
+
|
32
34
|
module Google
|
33
35
|
module Gax
|
34
36
|
# Common base class for exceptions raised by GAX.
|
35
37
|
class GaxError < StandardError
|
38
|
+
attr_reader :details
|
39
|
+
|
36
40
|
# @param msg [String] describes the error that occurred.
|
37
41
|
def initialize(msg)
|
38
42
|
msg = "GaxError #{msg}"
|
39
43
|
msg += ", caused by #{$ERROR_INFO}" if $ERROR_INFO
|
40
44
|
super(msg)
|
41
45
|
@cause = $ERROR_INFO
|
46
|
+
@details = Google::Gax::Grpc.deserialize_error_status_details(@cause)
|
42
47
|
end
|
43
48
|
|
44
49
|
# cause is a new method introduced in 2.1.0, bring this
|
data/lib/google/gax/grpc.rb
CHANGED
@@ -28,8 +28,12 @@
|
|
28
28
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
29
|
|
30
30
|
require 'grpc'
|
31
|
+
require 'grpc/google_rpc_status_utils'
|
31
32
|
require 'googleauth'
|
32
33
|
require 'google/gax/errors'
|
34
|
+
require 'google/protobuf/well_known_types'
|
35
|
+
# Required in order to deserialize common error detail proto types
|
36
|
+
require 'google/rpc/error_details_pb'
|
33
37
|
|
34
38
|
module Google
|
35
39
|
module Gax
|
@@ -43,6 +47,35 @@ module Google
|
|
43
47
|
|
44
48
|
API_ERRORS = [GRPC::BadStatus, GRPC::Cancelled].freeze
|
45
49
|
|
50
|
+
def deserialize_error_status_details(error)
|
51
|
+
return unless error.is_a? GRPC::BadStatus
|
52
|
+
# If error status is malformed, swallow the gRPC error that gets raised.
|
53
|
+
begin
|
54
|
+
details =
|
55
|
+
GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
|
56
|
+
error.to_status
|
57
|
+
).details
|
58
|
+
rescue
|
59
|
+
return 'Could not parse error details due to a malformed server '\
|
60
|
+
'response trailer.'
|
61
|
+
end
|
62
|
+
return if details.nil?
|
63
|
+
details =
|
64
|
+
GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
|
65
|
+
error.to_status
|
66
|
+
).details
|
67
|
+
details.map do |any|
|
68
|
+
# If the type of the proto wrapped by the Any instance is not
|
69
|
+
# available, do not deserialize.
|
70
|
+
candidate_class_name = class_case(any.type_name.split('.')).join('::')
|
71
|
+
begin
|
72
|
+
any.unpack(Object.const_get(candidate_class_name))
|
73
|
+
rescue NameError
|
74
|
+
any
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
46
79
|
# rubocop:disable Metrics/ParameterLists
|
47
80
|
|
48
81
|
# Creates a gRPC client stub.
|
@@ -97,7 +130,7 @@ module Google
|
|
97
130
|
end
|
98
131
|
end
|
99
132
|
|
100
|
-
module_function :create_stub
|
133
|
+
module_function :create_stub, :deserialize_error_status_details
|
101
134
|
|
102
135
|
def self.verify_params(channel, chan_creds, updater_proc)
|
103
136
|
if (channel && chan_creds) ||
|
@@ -109,7 +142,15 @@ module Google
|
|
109
142
|
end
|
110
143
|
end
|
111
144
|
|
112
|
-
|
145
|
+
# Capitalize all modules except the message class, which is already
|
146
|
+
# correctly cased
|
147
|
+
def self.class_case(modules)
|
148
|
+
message = modules.pop
|
149
|
+
modules = modules.map(&:capitalize)
|
150
|
+
modules << message
|
151
|
+
end
|
152
|
+
|
153
|
+
private_class_method :verify_params, :class_case
|
113
154
|
end
|
114
155
|
end
|
115
156
|
end
|
data/lib/google/gax/operation.rb
CHANGED
File without changes
|
File without changes
|
data/lib/google/gax/settings.rb
CHANGED
File without changes
|
data/lib/google/gax/util.rb
CHANGED
@@ -42,12 +42,21 @@ module Google
|
|
42
42
|
# messages using hashes but does not allow for nested hashes to instantiate
|
43
43
|
# nested submessages.
|
44
44
|
#
|
45
|
-
# @param hash [Hash] The hash to be converted into a proto message.
|
45
|
+
# @param hash [Hash || Class] The hash to be converted into a proto message.
|
46
|
+
# If an instance of the proto message class is given, it is returned
|
47
|
+
# unchanged.
|
46
48
|
# @param message_class [Class] The corresponding protobuf message class of
|
47
49
|
# the given hash.
|
48
50
|
#
|
49
51
|
# @return [Object] An instance of the given message class.
|
50
52
|
def to_proto(hash, message_class)
|
53
|
+
return hash if hash.is_a? message_class
|
54
|
+
|
55
|
+
# Sanity check: input must be a Hash
|
56
|
+
unless hash.is_a? Hash
|
57
|
+
raise ArgumentError,
|
58
|
+
"Value #{hash} must be a Hash or a #{message_class.name}"
|
59
|
+
end
|
51
60
|
hash = coerce_submessages(hash, message_class)
|
52
61
|
message_class.new(hash)
|
53
62
|
end
|
data/lib/google/gax/version.rb
CHANGED
data/lib/google/gax/version.rb~
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/spec/fixtures/fixture.proto
CHANGED
File without changes
|
data/spec/fixtures/fixture_pb.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -28,6 +28,7 @@
|
|
28
28
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
29
|
|
30
30
|
require 'google/gax'
|
31
|
+
require 'google/protobuf/any_pb'
|
31
32
|
require 'spec/fixtures/fixture_pb'
|
32
33
|
|
33
34
|
describe Google::Gax do
|
@@ -118,5 +119,20 @@ describe Google::Gax do
|
|
118
119
|
Google::Gax.to_proto(user_hash, Google::Protobuf::User)
|
119
120
|
end.to raise_error(ArgumentError)
|
120
121
|
end
|
122
|
+
|
123
|
+
it 'handles proto messages' do
|
124
|
+
user_message = Google::Protobuf::User.new(
|
125
|
+
name: USER_NAME, type: USER_TYPE
|
126
|
+
)
|
127
|
+
user = Google::Gax.to_proto(user_message, Google::Protobuf::User)
|
128
|
+
expect(user).to eq user_message
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'fails if proto message has unexpected type' do
|
132
|
+
user_message = Google::Protobuf::Any
|
133
|
+
expect do
|
134
|
+
Google::Gax.to_proto(user_message, Google::Protobuf::User)
|
135
|
+
end.to raise_error(ArgumentError)
|
136
|
+
end
|
121
137
|
end
|
122
138
|
end
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-gax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.12
|
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: 2017-
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: googleauth
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.6.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.6.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: googleapis-common-protos
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|