grpc 1.6.0 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7a4fcbd8a63b29189c8fbc7e973a2dcf5552741
4
- data.tar.gz: d9f27e5fe2be71436abf85c269d092e59bddc185
3
+ metadata.gz: 6420473df99c7304193775fb989314d7c6b7ba23
4
+ data.tar.gz: 919eacd2969e2b55532f677b232c6726dc017e3f
5
5
  SHA512:
6
- metadata.gz: 2830b776877762531fd8e13ead565c298811252324203910bdb4d8b801e54eb7ac9964be965e23dd7595f7b69068925a58470dab13dc8928a1c694cbf63c6535
7
- data.tar.gz: 2a4c2e0bb530e9940cd23cc12a5d7e8e290ce65ee774232ed3089c5ae4b97a304fd551f41f6aff139063a59b7ec0587bbb4f9991bca45597df6f6412d083fb75
6
+ metadata.gz: b2968cc946b4c07ca2bf19d5d0e7d8a628fd58e3c187e21509849d42caa7062b3f53fc35c4496b2459f682f97e93c6907ef0130b46ec7c1f344d3622e57ff604
7
+ data.tar.gz: 9207834cea409f50235d25764d35f5dc7e96946719ce40e584420d594b8c590ea9bd5c5fbf747f0812d3a7ddbfb36186537e68115b0f56c4636bca84491b3705
data/Makefile CHANGED
@@ -411,8 +411,8 @@ Q = @
411
411
  endif
412
412
 
413
413
  CORE_VERSION = 4.0.0
414
- CPP_VERSION = 1.6.0
415
- CSHARP_VERSION = 1.6.0
414
+ CPP_VERSION = 1.6.2
415
+ CSHARP_VERSION = 1.6.2
416
416
 
417
417
  CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
418
418
  CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
@@ -0,0 +1,28 @@
1
+ # Copyright 2017 gRPC authors.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative './grpc'
16
+ require 'google/rpc/status_pb'
17
+
18
+ # GRPC contains the General RPC module.
19
+ module GRPC
20
+ # GoogleRpcStatusUtils provides utilities to convert between a
21
+ # GRPC::Core::Status and a deserialized Google::Rpc::Status proto
22
+ class GoogleRpcStatusUtils
23
+ def self.extract_google_rpc_status(status)
24
+ fail ArgumentError, 'bad type' unless status.is_a? Struct::Status
25
+ Google::Rpc::Status.decode(status.metadata['grpc-status-details-bin'])
26
+ end
27
+ end
28
+ end
@@ -14,5 +14,5 @@
14
14
 
15
15
  # GRPC contains the General RPC module.
16
16
  module GRPC
17
- VERSION = '1.6.0'
17
+ VERSION = '1.6.2'
18
18
  end
@@ -0,0 +1,223 @@
1
+ # Copyright 2017 gRPC authors.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'grpc'
16
+ require_relative '../lib/grpc/google_rpc_status_utils'
17
+ require_relative '../pb/src/proto/grpc/testing/messages_pb'
18
+ require_relative '../pb/src/proto/grpc/testing/messages_pb'
19
+ require 'google/protobuf/well_known_types'
20
+
21
+ include GRPC::Core
22
+
23
+ describe 'conversion from a status struct to a google protobuf status' do
24
+ it 'fails if the input is not a status struct' do
25
+ begin
26
+ GRPC::GoogleRpcStatusUtils.extract_google_rpc_status('string')
27
+ rescue => e
28
+ exception = e
29
+ end
30
+ expect(exception.is_a?(ArgumentError)).to be true
31
+ expect(exception.message.include?('bad type')).to be true
32
+ end
33
+
34
+ it 'fails with some error if the header key is missing' do
35
+ status = Struct::Status.new(1, 'details', key: 'val')
36
+ expect(status.metadata.nil?).to be false
37
+ expect do
38
+ GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(status)
39
+ end.to raise_error(StandardError)
40
+ end
41
+
42
+ it 'fails with some error if the header key fails to deserialize' do
43
+ status = Struct::Status.new(1, 'details',
44
+ 'grpc-status-details-bin' => 'string_val')
45
+ expect do
46
+ GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(status)
47
+ end.to raise_error(StandardError)
48
+ end
49
+
50
+ it 'silently ignores erroneous mismatch between messages in '\
51
+ 'status struct and protobuf status' do
52
+ proto = Google::Rpc::Status.new(code: 1, message: 'proto message')
53
+ encoded_proto = Google::Rpc::Status.encode(proto)
54
+ status = Struct::Status.new(1, 'struct message',
55
+ 'grpc-status-details-bin' => encoded_proto)
56
+ rpc_status = GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(status)
57
+ expect(rpc_status).to eq(proto)
58
+ end
59
+
60
+ it 'silently ignores erroneous mismatch between codes in status struct '\
61
+ 'and protobuf status' do
62
+ proto = Google::Rpc::Status.new(code: 1, message: 'matching message')
63
+ encoded_proto = Google::Rpc::Status.encode(proto)
64
+ status = Struct::Status.new(2, 'matching message',
65
+ 'grpc-status-details-bin' => encoded_proto)
66
+ rpc_status = GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(status)
67
+ expect(rpc_status).to eq(proto)
68
+ end
69
+
70
+ it 'can succesfully convert a status struct into a google protobuf status '\
71
+ 'when there are no rpcstatus details' do
72
+ proto = Google::Rpc::Status.new(code: 1, message: 'matching message')
73
+ encoded_proto = Google::Rpc::Status.encode(proto)
74
+ status = Struct::Status.new(1, 'matching message',
75
+ 'grpc-status-details-bin' => encoded_proto)
76
+ out = GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(status)
77
+ expect(out.code).to eq(1)
78
+ expect(out.message).to eq('matching message')
79
+ expect(out.details).to eq([])
80
+ end
81
+
82
+ it 'can succesfully convert a status struct into a google protobuf '\
83
+ 'status when there are multiple rpcstatus details' do
84
+ simple_request_any = Google::Protobuf::Any.new
85
+ simple_request = Grpc::Testing::SimpleRequest.new(
86
+ payload: Grpc::Testing::Payload.new(body: 'request'))
87
+ simple_request_any.pack(simple_request)
88
+ simple_response_any = Google::Protobuf::Any.new
89
+ simple_response = Grpc::Testing::SimpleResponse.new(
90
+ payload: Grpc::Testing::Payload.new(body: 'response'))
91
+ simple_response_any.pack(simple_response)
92
+ payload_any = Google::Protobuf::Any.new
93
+ payload = Grpc::Testing::Payload.new(body: 'payload')
94
+ payload_any.pack(payload)
95
+ proto = Google::Rpc::Status.new(code: 1,
96
+ message: 'matching message',
97
+ details: [
98
+ simple_request_any,
99
+ simple_response_any,
100
+ payload_any
101
+ ])
102
+ encoded_proto = Google::Rpc::Status.encode(proto)
103
+ status = Struct::Status.new(1, 'matching message',
104
+ 'grpc-status-details-bin' => encoded_proto)
105
+ out = GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(status)
106
+ expect(out.code).to eq(1)
107
+ expect(out.message).to eq('matching message')
108
+ expect(out.details[0].unpack(
109
+ Grpc::Testing::SimpleRequest)).to eq(simple_request)
110
+ expect(out.details[1].unpack(
111
+ Grpc::Testing::SimpleResponse)).to eq(simple_response)
112
+ expect(out.details[2].unpack(
113
+ Grpc::Testing::Payload)).to eq(payload)
114
+ end
115
+ end
116
+
117
+ # Test message
118
+ class EchoMsg
119
+ def self.marshal(_o)
120
+ ''
121
+ end
122
+
123
+ def self.unmarshal(_o)
124
+ EchoMsg.new
125
+ end
126
+ end
127
+
128
+ # A test service that fills in the "reserved" grpc-status-details-bin trailer,
129
+ # for client-side testing of GoogleRpcStatus protobuf extraction from trailers.
130
+ class GoogleRpcStatusTestService
131
+ include GRPC::GenericService
132
+ rpc :an_rpc, EchoMsg, EchoMsg
133
+
134
+ def initialize(encoded_rpc_status)
135
+ @encoded_rpc_status = encoded_rpc_status
136
+ end
137
+
138
+ def an_rpc(_, _)
139
+ # TODO: create a server-side utility API for sending a google rpc status.
140
+ # Applications are not expected to set the grpc-status-details-bin
141
+ # ("grpc"-fixed and reserved for library use) manually.
142
+ # Doing so here is only for testing of the client-side api for extracting
143
+ # a google rpc status, which is useful
144
+ # when the interacting with a server that does fill in this trailer.
145
+ fail GRPC::Unknown.new('test message',
146
+ 'grpc-status-details-bin' => @encoded_rpc_status)
147
+ end
148
+ end
149
+
150
+ GoogleRpcStatusTestStub = GoogleRpcStatusTestService.rpc_stub_class
151
+
152
+ describe 'receving a google rpc status from a remote endpoint' do
153
+ def start_server(encoded_rpc_status)
154
+ @srv = GRPC::RpcServer.new(pool_size: 1)
155
+ @server_port = @srv.add_http2_port('localhost:0',
156
+ :this_port_is_insecure)
157
+ @srv.handle(GoogleRpcStatusTestService.new(encoded_rpc_status))
158
+ @server_thd = Thread.new { @srv.run }
159
+ @srv.wait_till_running
160
+ end
161
+
162
+ def stop_server
163
+ expect(@srv.stopped?).to be(false)
164
+ @srv.stop
165
+ @server_thd.join
166
+ expect(@srv.stopped?).to be(true)
167
+ end
168
+
169
+ before(:each) do
170
+ simple_request_any = Google::Protobuf::Any.new
171
+ simple_request = Grpc::Testing::SimpleRequest.new(
172
+ payload: Grpc::Testing::Payload.new(body: 'request'))
173
+ simple_request_any.pack(simple_request)
174
+ simple_response_any = Google::Protobuf::Any.new
175
+ simple_response = Grpc::Testing::SimpleResponse.new(
176
+ payload: Grpc::Testing::Payload.new(body: 'response'))
177
+ simple_response_any.pack(simple_response)
178
+ payload_any = Google::Protobuf::Any.new
179
+ payload = Grpc::Testing::Payload.new(body: 'payload')
180
+ payload_any.pack(payload)
181
+ @expected_proto = Google::Rpc::Status.new(
182
+ code: StatusCodes::UNKNOWN,
183
+ message: 'test message',
184
+ details: [simple_request_any, simple_response_any, payload_any])
185
+ start_server(Google::Rpc::Status.encode(@expected_proto))
186
+ end
187
+
188
+ after(:each) do
189
+ stop_server
190
+ end
191
+
192
+ it 'should receive be able to extract a google rpc status from the '\
193
+ 'status struct taken from a BadStatus exception' do
194
+ stub = GoogleRpcStatusTestStub.new("localhost:#{@server_port}",
195
+ :this_channel_is_insecure)
196
+ begin
197
+ stub.an_rpc(EchoMsg.new)
198
+ rescue GRPC::BadStatus => e
199
+ rpc_status = GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
200
+ e.to_status)
201
+ end
202
+ expect(rpc_status).to eq(@expected_proto)
203
+ end
204
+
205
+ it 'should receive be able to extract a google rpc status from the '\
206
+ 'status struct taken from the op view of a call' do
207
+ stub = GoogleRpcStatusTestStub.new("localhost:#{@server_port}",
208
+ :this_channel_is_insecure)
209
+ op = stub.an_rpc(EchoMsg.new, return_op: true)
210
+ begin
211
+ op.execute
212
+ rescue GRPC::BadStatus => e
213
+ status_from_exception = e.to_status
214
+ end
215
+ rpc_status = GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
216
+ op.status)
217
+ expect(rpc_status).to eq(@expected_proto)
218
+ # "to_status" on the bad status should give the same result
219
+ # as "status" on the "op view".
220
+ expect(GRPC::GoogleRpcStatusUtils.extract_google_rpc_status(
221
+ status_from_exception)).to eq(rpc_status)
222
+ end
223
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - gRPC Authors
8
8
  autorequire:
9
9
  bindir: src/ruby/bin
10
10
  cert_chain: []
11
- date: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.5.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: googleapis-common-protos-types
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -836,6 +850,7 @@ files:
836
850
  - src/ruby/lib/grpc/generic/rpc_desc.rb
837
851
  - src/ruby/lib/grpc/generic/rpc_server.rb
838
852
  - src/ruby/lib/grpc/generic/service.rb
853
+ - src/ruby/lib/grpc/google_rpc_status_utils.rb
839
854
  - src/ruby/lib/grpc/grpc.rb
840
855
  - src/ruby/lib/grpc/logconfig.rb
841
856
  - src/ruby/lib/grpc/notifier.rb
@@ -869,6 +884,7 @@ files:
869
884
  - src/ruby/spec/generic/rpc_server_pool_spec.rb
870
885
  - src/ruby/spec/generic/rpc_server_spec.rb
871
886
  - src/ruby/spec/generic/service_spec.rb
887
+ - src/ruby/spec/google_rpc_status_utils_spec.rb
872
888
  - src/ruby/spec/pb/duplicate/codegen_spec.rb
873
889
  - src/ruby/spec/pb/health/checker_spec.rb
874
890
  - src/ruby/spec/server_credentials_spec.rb
@@ -1430,6 +1446,7 @@ test_files:
1430
1446
  - src/ruby/spec/testdata/server1.pem
1431
1447
  - src/ruby/spec/testdata/client.key
1432
1448
  - src/ruby/spec/time_consts_spec.rb
1449
+ - src/ruby/spec/google_rpc_status_utils_spec.rb
1433
1450
  - src/ruby/spec/channel_connection_spec.rb
1434
1451
  - src/ruby/spec/call_spec.rb
1435
1452
  - src/ruby/spec/generic/rpc_server_spec.rb