grpc 1.12.0-x86-mingw32 → 1.13.0.pre1-x86-mingw32
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 +4 -4
- data/grpc_c.32.ruby +0 -0
- data/grpc_c.64.ruby +0 -0
- data/src/ruby/bin/math_client.rb +17 -9
- data/src/ruby/lib/grpc/2.0/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.1/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.2/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.3/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.4/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.5/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +4 -1
- data/src/ruby/pb/test/client.rb +1 -1
- metadata +49 -53
- data/src/ruby/bin/apis/google/protobuf/empty.rb +0 -29
- data/src/ruby/bin/apis/pubsub_demo.rb +0 -241
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb +0 -159
- data/src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02e936f934a43647cca0fe2056d4e0b733ee0c023b669b9b06090095d9525ad2
|
4
|
+
data.tar.gz: f16e52ccee52df2f20881abb0c5e6ba66f957ab50636802281633b23e1bc23c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c023cc16e7c307ec98f4eb2ec58cf87e6538e9ee84820f3b851773fd031cf6a0247bee4828f7eb94657a33ca0f21a648a2f548eaaf9f1a228ba6515f7cd88e90
|
7
|
+
data.tar.gz: 887ff7cc417ec5f6dd2095adb448bc18895a471badedd42ec11929428bc2b66873080bc3466b90f7cc28189b2333905befb3a705eecab2be7029d7380094a2e7
|
data/grpc_c.32.ruby
CHANGED
Binary file
|
data/grpc_c.64.ruby
CHANGED
Binary file
|
data/src/ruby/bin/math_client.rb
CHANGED
@@ -27,15 +27,26 @@ $LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir)
|
|
27
27
|
require 'grpc'
|
28
28
|
require 'math_services_pb'
|
29
29
|
require 'optparse'
|
30
|
+
require 'logger'
|
30
31
|
|
31
32
|
include GRPC::Core::TimeConsts
|
32
33
|
|
34
|
+
module StdoutLogger
|
35
|
+
def logger
|
36
|
+
LOGGER
|
37
|
+
end
|
38
|
+
|
39
|
+
LOGGER = Logger.new(STDOUT)
|
40
|
+
end
|
41
|
+
|
42
|
+
GRPC.extend(StdoutLogger)
|
43
|
+
|
33
44
|
def do_div(stub)
|
34
45
|
GRPC.logger.info('request_response')
|
35
46
|
GRPC.logger.info('----------------')
|
36
47
|
req = Math::DivArgs.new(dividend: 7, divisor: 3)
|
37
48
|
GRPC.logger.info("div(7/3): req=#{req.inspect}")
|
38
|
-
resp = stub.div(req
|
49
|
+
resp = stub.div(req)
|
39
50
|
GRPC.logger.info("Answer: #{resp.inspect}")
|
40
51
|
GRPC.logger.info('----------------')
|
41
52
|
end
|
@@ -56,7 +67,7 @@ def do_fib(stub)
|
|
56
67
|
GRPC.logger.info('----------------')
|
57
68
|
req = Math::FibArgs.new(limit: 11)
|
58
69
|
GRPC.logger.info("fib(11): req=#{req.inspect}")
|
59
|
-
resp = stub.fib(req
|
70
|
+
resp = stub.fib(req)
|
60
71
|
resp.each do |r|
|
61
72
|
GRPC.logger.info("Answer: #{r.inspect}")
|
62
73
|
end
|
@@ -71,7 +82,7 @@ def do_div_many(stub)
|
|
71
82
|
reqs << Math::DivArgs.new(dividend: 5, divisor: 2)
|
72
83
|
reqs << Math::DivArgs.new(dividend: 7, divisor: 2)
|
73
84
|
GRPC.logger.info("div(7/3), div(5/2), div(7/2): reqs=#{reqs.inspect}")
|
74
|
-
resp = stub.div_many(reqs
|
85
|
+
resp = stub.div_many(reqs)
|
75
86
|
resp.each do |r|
|
76
87
|
GRPC.logger.info("Answer: #{r.inspect}")
|
77
88
|
end
|
@@ -107,19 +118,16 @@ def main
|
|
107
118
|
|
108
119
|
# The Math::Math:: module occurs because the service has the same name as its
|
109
120
|
# package. That practice should be avoided by defining real services.
|
110
|
-
|
111
|
-
p options
|
112
121
|
if options['secure']
|
113
122
|
stub_opts = {
|
114
123
|
:creds => test_creds,
|
115
|
-
GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr'
|
124
|
+
GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr',
|
125
|
+
timeout: INFINITE_FUTURE,
|
116
126
|
}
|
117
|
-
p stub_opts
|
118
|
-
p options['host']
|
119
127
|
stub = Math::Math::Stub.new(options['host'], **stub_opts)
|
120
128
|
GRPC.logger.info("... connecting securely on #{options['host']}")
|
121
129
|
else
|
122
|
-
stub = Math::Math::Stub.new(options['host'])
|
130
|
+
stub = Math::Math::Stub.new(options['host'], :this_channel_is_insecure, timeout: INFINITE_FUTURE)
|
123
131
|
GRPC.logger.info("... connecting insecurely on #{options['host']}")
|
124
132
|
end
|
125
133
|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -364,7 +364,8 @@ module GRPC
|
|
364
364
|
# sent yet
|
365
365
|
c = ActiveCall.new(an_rpc.call, noop, noop, an_rpc.deadline,
|
366
366
|
metadata_received: true, started: false)
|
367
|
-
c.send_status(GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED,
|
367
|
+
c.send_status(GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED,
|
368
|
+
'No free threads in thread pool')
|
368
369
|
nil
|
369
370
|
end
|
370
371
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
2
|
# Source: grpc/health/v1/health.proto for package 'grpc.health.v1'
|
3
3
|
# Original file comments:
|
4
|
-
# Copyright 2015 gRPC
|
4
|
+
# Copyright 2015 The gRPC Authors
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -15,6 +15,9 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
|
+
# The canonical version of this proto can be found at
|
19
|
+
# https://github.com/grpc/grpc-proto/blob/master/grpc/health/v1/health.proto
|
20
|
+
#
|
18
21
|
|
19
22
|
require 'grpc'
|
20
23
|
require 'grpc/health/v1/health_pb'
|
data/src/ruby/pb/test/client.rb
CHANGED
@@ -734,7 +734,7 @@ def parse_args
|
|
734
734
|
opts.on('--use_tls USE_TLS', ['false', 'true'],
|
735
735
|
'require a secure connection?') do |v|
|
736
736
|
args['secure'] = v == 'true'
|
737
|
-
|
737
|
+
end
|
738
738
|
opts.on('--use_test_ca USE_TEST_CA', ['false', 'true'],
|
739
739
|
'if secure, use the test certificate?') do |v|
|
740
740
|
args['use_test_ca'] = v == 'true'
|
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.
|
4
|
+
version: 1.13.0.pre1
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- gRPC Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: src/ruby/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -24,26 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: googleauth
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.5.1
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '0.7'
|
37
|
-
type: :runtime
|
38
|
-
prerelease: false
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 0.5.1
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0.7'
|
47
27
|
- !ruby/object:Gem::Dependency
|
48
28
|
name: googleapis-common-protos-types
|
49
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,6 +178,26 @@ dependencies:
|
|
198
178
|
- - "~>"
|
199
179
|
- !ruby/object:Gem::Version
|
200
180
|
version: 0.7.0
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: googleauth
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.5.1
|
188
|
+
- - "<"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0.7'
|
191
|
+
type: :development
|
192
|
+
prerelease: false
|
193
|
+
version_requirements: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: 0.5.1
|
198
|
+
- - "<"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0.7'
|
201
201
|
description: Send RPCs from Ruby using GRPC
|
202
202
|
email: temiola@google.com
|
203
203
|
executables: []
|
@@ -207,10 +207,6 @@ files:
|
|
207
207
|
- etc/roots.pem
|
208
208
|
- grpc_c.32.ruby
|
209
209
|
- grpc_c.64.ruby
|
210
|
-
- src/ruby/bin/apis/google/protobuf/empty.rb
|
211
|
-
- src/ruby/bin/apis/pubsub_demo.rb
|
212
|
-
- src/ruby/bin/apis/tech/pubsub/proto/pubsub.rb
|
213
|
-
- src/ruby/bin/apis/tech/pubsub/proto/pubsub_services.rb
|
214
210
|
- src/ruby/bin/math_client.rb
|
215
211
|
- src/ruby/bin/math_pb.rb
|
216
212
|
- src/ruby/bin/math_server.rb
|
@@ -338,49 +334,49 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
338
334
|
version: '2.6'
|
339
335
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
340
336
|
requirements:
|
341
|
-
- - "
|
337
|
+
- - ">"
|
342
338
|
- !ruby/object:Gem::Version
|
343
|
-
version:
|
339
|
+
version: 1.3.1
|
344
340
|
requirements: []
|
345
341
|
rubyforge_project:
|
346
|
-
rubygems_version: 2.7.
|
342
|
+
rubygems_version: 2.7.7
|
347
343
|
signing_key:
|
348
344
|
specification_version: 4
|
349
345
|
summary: GRPC system in Ruby
|
350
346
|
test_files:
|
351
|
-
- src/ruby/spec/
|
352
|
-
- src/ruby/spec/
|
353
|
-
- src/ruby/spec/
|
354
|
-
- src/ruby/spec/support/services.rb
|
347
|
+
- src/ruby/spec/client_server_spec.rb
|
348
|
+
- src/ruby/spec/error_sanity_spec.rb
|
349
|
+
- src/ruby/spec/call_spec.rb
|
355
350
|
- src/ruby/spec/support/helpers.rb
|
356
|
-
- src/ruby/spec/
|
351
|
+
- src/ruby/spec/support/services.rb
|
357
352
|
- src/ruby/spec/server_credentials_spec.rb
|
358
|
-
- src/ruby/spec/
|
353
|
+
- src/ruby/spec/compression_options_spec.rb
|
354
|
+
- src/ruby/spec/channel_connection_spec.rb
|
355
|
+
- src/ruby/spec/call_credentials_spec.rb
|
356
|
+
- src/ruby/spec/channel_credentials_spec.rb
|
357
|
+
- src/ruby/spec/google_rpc_status_utils_spec.rb
|
359
358
|
- src/ruby/spec/generic/rpc_desc_spec.rb
|
360
|
-
- src/ruby/spec/generic/active_call_spec.rb
|
361
|
-
- src/ruby/spec/generic/server_interceptors_spec.rb
|
362
|
-
- src/ruby/spec/generic/service_spec.rb
|
363
359
|
- src/ruby/spec/generic/rpc_server_spec.rb
|
360
|
+
- src/ruby/spec/generic/interceptor_registry_spec.rb
|
361
|
+
- src/ruby/spec/generic/rpc_server_pool_spec.rb
|
364
362
|
- src/ruby/spec/generic/client_stub_spec.rb
|
365
363
|
- src/ruby/spec/generic/client_interceptors_spec.rb
|
366
|
-
- src/ruby/spec/generic/
|
367
|
-
- src/ruby/spec/
|
368
|
-
- src/ruby/spec/
|
369
|
-
- src/ruby/spec/google_rpc_status_utils_spec.rb
|
370
|
-
- src/ruby/spec/compression_options_spec.rb
|
371
|
-
- src/ruby/spec/error_sanity_spec.rb
|
372
|
-
- src/ruby/spec/call_credentials_spec.rb
|
373
|
-
- src/ruby/spec/channel_credentials_spec.rb
|
374
|
-
- src/ruby/spec/pb/health/checker_spec.rb
|
375
|
-
- src/ruby/spec/pb/package_with_underscore/service.proto
|
376
|
-
- src/ruby/spec/pb/package_with_underscore/data.proto
|
377
|
-
- src/ruby/spec/pb/package_with_underscore/checker_spec.rb
|
378
|
-
- src/ruby/spec/pb/duplicate/codegen_spec.rb
|
364
|
+
- src/ruby/spec/generic/server_interceptors_spec.rb
|
365
|
+
- src/ruby/spec/generic/service_spec.rb
|
366
|
+
- src/ruby/spec/generic/active_call_spec.rb
|
379
367
|
- src/ruby/spec/testdata/client.pem
|
380
368
|
- src/ruby/spec/testdata/ca.pem
|
381
|
-
- src/ruby/spec/testdata/server1.key
|
382
369
|
- src/ruby/spec/testdata/client.key
|
383
370
|
- src/ruby/spec/testdata/server1.pem
|
371
|
+
- src/ruby/spec/testdata/server1.key
|
384
372
|
- src/ruby/spec/testdata/README
|
385
|
-
- src/ruby/spec/call_spec.rb
|
386
373
|
- src/ruby/spec/client_auth_spec.rb
|
374
|
+
- src/ruby/spec/pb/package_with_underscore/checker_spec.rb
|
375
|
+
- src/ruby/spec/pb/package_with_underscore/service.proto
|
376
|
+
- src/ruby/spec/pb/package_with_underscore/data.proto
|
377
|
+
- src/ruby/spec/pb/health/checker_spec.rb
|
378
|
+
- src/ruby/spec/pb/duplicate/codegen_spec.rb
|
379
|
+
- src/ruby/spec/time_consts_spec.rb
|
380
|
+
- src/ruby/spec/server_spec.rb
|
381
|
+
- src/ruby/spec/spec_helper.rb
|
382
|
+
- src/ruby/spec/channel_spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# Copyright 2015 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
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
16
|
-
# source: google/protobuf/empty.proto
|
17
|
-
|
18
|
-
require 'google/protobuf'
|
19
|
-
|
20
|
-
Google::Protobuf::DescriptorPool.generated_pool.build do
|
21
|
-
add_message "google.protobuf.Empty" do
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
module Google
|
26
|
-
module Protobuf
|
27
|
-
Empty = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.protobuf.Empty").msgclass
|
28
|
-
end
|
29
|
-
end
|
@@ -1,241 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Copyright 2015 gRPC authors.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
# pubsub_demo demos accesses the Google PubSub API via its gRPC interface
|
18
|
-
#
|
19
|
-
# $ GOOGLE_APPLICATION_CREDENTIALS=<path_to_service_account_key_file> \
|
20
|
-
# path/to/pubsub_demo.rb \
|
21
|
-
# [--action=<chosen_demo_action> ]
|
22
|
-
#
|
23
|
-
# There are options related to the chosen action, see #parse_args below.
|
24
|
-
# - the possible actions are given by the method names of NamedAction class
|
25
|
-
# - the default action is list_some_topics
|
26
|
-
|
27
|
-
this_dir = File.expand_path(File.dirname(__FILE__))
|
28
|
-
lib_dir = File.join(File.dirname(File.dirname(this_dir)), 'lib')
|
29
|
-
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
30
|
-
$LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir)
|
31
|
-
|
32
|
-
require 'optparse'
|
33
|
-
|
34
|
-
require 'grpc'
|
35
|
-
require 'googleauth'
|
36
|
-
require 'google/protobuf'
|
37
|
-
|
38
|
-
require 'google/protobuf/empty'
|
39
|
-
require 'tech/pubsub/proto/pubsub'
|
40
|
-
require 'tech/pubsub/proto/pubsub_services'
|
41
|
-
|
42
|
-
# creates a SSL Credentials from the production certificates.
|
43
|
-
def ssl_creds
|
44
|
-
GRPC::Core::ChannelCredentials.new()
|
45
|
-
end
|
46
|
-
|
47
|
-
# Builds the metadata authentication update proc.
|
48
|
-
def auth_proc(opts)
|
49
|
-
auth_creds = Google::Auth.get_application_default
|
50
|
-
return auth_creds.updater_proc
|
51
|
-
end
|
52
|
-
|
53
|
-
# Creates a stub for accessing the publisher service.
|
54
|
-
def publisher_stub(opts)
|
55
|
-
address = "#{opts.host}:#{opts.port}"
|
56
|
-
stub_clz = Tech::Pubsub::PublisherService::Stub # shorter
|
57
|
-
GRPC.logger.info("... access PublisherService at #{address}")
|
58
|
-
call_creds = GRPC::Core::CallCredentials.new(auth_proc(opts))
|
59
|
-
combined_creds = ssl_creds.compose(call_creds)
|
60
|
-
stub_clz.new(address, creds: combined_creds,
|
61
|
-
GRPC::Core::Channel::SSL_TARGET => opts.host)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Creates a stub for accessing the subscriber service.
|
65
|
-
def subscriber_stub(opts)
|
66
|
-
address = "#{opts.host}:#{opts.port}"
|
67
|
-
stub_clz = Tech::Pubsub::SubscriberService::Stub # shorter
|
68
|
-
GRPC.logger.info("... access SubscriberService at #{address}")
|
69
|
-
call_creds = GRPC::Core::CallCredentials.new(auth_proc(opts))
|
70
|
-
combined_creds = ssl_creds.compose(call_creds)
|
71
|
-
stub_clz.new(address, creds: combined_creds,
|
72
|
-
GRPC::Core::Channel::SSL_TARGET => opts.host)
|
73
|
-
end
|
74
|
-
|
75
|
-
# defines methods corresponding to each interop test case.
|
76
|
-
class NamedActions
|
77
|
-
include Tech::Pubsub
|
78
|
-
|
79
|
-
# Initializes NamedActions
|
80
|
-
#
|
81
|
-
# @param pub [Stub] a stub for accessing the publisher service
|
82
|
-
# @param sub [Stub] a stub for accessing the publisher service
|
83
|
-
# @param args [Args] provides access to the command line
|
84
|
-
def initialize(pub, sub, args)
|
85
|
-
@pub = pub
|
86
|
-
@sub = sub
|
87
|
-
@args = args
|
88
|
-
end
|
89
|
-
|
90
|
-
# Removes the test topic if it exists
|
91
|
-
def remove_topic
|
92
|
-
name = test_topic_name
|
93
|
-
p "... removing Topic #{name}"
|
94
|
-
@pub.delete_topic(DeleteTopicRequest.new(topic: name))
|
95
|
-
p "removed Topic: #{name} OK"
|
96
|
-
rescue GRPC::BadStatus => e
|
97
|
-
p "Could not delete a topics: rpc failed with '#{e}'"
|
98
|
-
end
|
99
|
-
|
100
|
-
# Creates a test topic
|
101
|
-
def create_topic
|
102
|
-
name = test_topic_name
|
103
|
-
p "... creating Topic #{name}"
|
104
|
-
resp = @pub.create_topic(Topic.new(name: name))
|
105
|
-
p "created Topic: #{resp.name} OK"
|
106
|
-
rescue GRPC::BadStatus => e
|
107
|
-
p "Could not create a topics: rpc failed with '#{e}'"
|
108
|
-
end
|
109
|
-
|
110
|
-
# Lists topics in the project
|
111
|
-
def list_some_topics
|
112
|
-
p 'Listing topics'
|
113
|
-
p '-------------_'
|
114
|
-
list_project_topics.topic.each { |t| p t.name }
|
115
|
-
rescue GRPC::BadStatus => e
|
116
|
-
p "Could not list topics: rpc failed with '#{e}'"
|
117
|
-
end
|
118
|
-
|
119
|
-
# Checks if a topics exists in a project
|
120
|
-
def check_exists
|
121
|
-
name = test_topic_name
|
122
|
-
p "... checking for topic #{name}"
|
123
|
-
exists = topic_exists?(name)
|
124
|
-
p "#{name} is a topic" if exists
|
125
|
-
p "#{name} is not a topic" unless exists
|
126
|
-
rescue GRPC::BadStatus => e
|
127
|
-
p "Could not check for a topics: rpc failed with '#{e}'"
|
128
|
-
end
|
129
|
-
|
130
|
-
# Publishes some messages
|
131
|
-
def random_pub_sub
|
132
|
-
topic_name, sub_name = test_topic_name, test_sub_name
|
133
|
-
create_topic_if_needed(topic_name)
|
134
|
-
@sub.create_subscription(Subscription.new(name: sub_name,
|
135
|
-
topic: topic_name))
|
136
|
-
msg_count = rand(10..30)
|
137
|
-
msg_count.times do |x|
|
138
|
-
msg = PubsubMessage.new(data: "message #{x}")
|
139
|
-
@pub.publish(PublishRequest.new(topic: topic_name, message: msg))
|
140
|
-
end
|
141
|
-
p "Sent #{msg_count} messages to #{topic_name}, checking for them now."
|
142
|
-
batch = @sub.pull_batch(PullBatchRequest.new(subscription: sub_name,
|
143
|
-
max_events: msg_count))
|
144
|
-
ack_ids = batch.pull_responses.map { |x| x.ack_id }
|
145
|
-
p "Got #{ack_ids.size} messages; acknowledging them.."
|
146
|
-
@sub.acknowledge(AcknowledgeRequest.new(subscription: sub_name,
|
147
|
-
ack_id: ack_ids))
|
148
|
-
p "Test messages were acknowledged OK, deleting the subscription"
|
149
|
-
del_req = DeleteSubscriptionRequest.new(subscription: sub_name)
|
150
|
-
@sub.delete_subscription(del_req)
|
151
|
-
rescue GRPC::BadStatus => e
|
152
|
-
p "Could not do random pub sub: rpc failed with '#{e}'"
|
153
|
-
end
|
154
|
-
|
155
|
-
private
|
156
|
-
|
157
|
-
# test_topic_name is the topic name to use in this test.
|
158
|
-
def test_topic_name
|
159
|
-
unless @args.topic_name.nil?
|
160
|
-
return "/topics/#{@args.project_id}/#{@args.topic_name}"
|
161
|
-
end
|
162
|
-
now_text = Time.now.utc.strftime('%Y%m%d%H%M%S%L')
|
163
|
-
"/topics/#{@args.project_id}/#{ENV['USER']}-#{now_text}"
|
164
|
-
end
|
165
|
-
|
166
|
-
# test_sub_name is the subscription name to use in this test.
|
167
|
-
def test_sub_name
|
168
|
-
unless @args.sub_name.nil?
|
169
|
-
return "/subscriptions/#{@args.project_id}/#{@args.sub_name}"
|
170
|
-
end
|
171
|
-
now_text = Time.now.utc.strftime('%Y%m%d%H%M%S%L')
|
172
|
-
"/subscriptions/#{@args.project_id}/#{ENV['USER']}-#{now_text}"
|
173
|
-
end
|
174
|
-
|
175
|
-
# determines if the topic name exists
|
176
|
-
def topic_exists?(name)
|
177
|
-
topics = list_project_topics.topic.map { |t| t.name }
|
178
|
-
topics.include?(name)
|
179
|
-
end
|
180
|
-
|
181
|
-
def create_topic_if_needed(name)
|
182
|
-
return if topic_exists?(name)
|
183
|
-
@pub.create_topic(Topic.new(name: name))
|
184
|
-
end
|
185
|
-
|
186
|
-
def list_project_topics
|
187
|
-
q = "cloud.googleapis.com/project in (/projects/#{@args.project_id})"
|
188
|
-
@pub.list_topics(ListTopicsRequest.new(query: q))
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
# Args is used to hold the command line info.
|
193
|
-
Args = Struct.new(:host, :port, :action, :project_id, :topic_name,
|
194
|
-
:sub_name)
|
195
|
-
|
196
|
-
# validates the command line options, returning them as an Arg.
|
197
|
-
def parse_args
|
198
|
-
args = Args.new('pubsub-staging.googleapis.com',
|
199
|
-
443, 'list_some_topics', 'stoked-keyword-656')
|
200
|
-
OptionParser.new do |opts|
|
201
|
-
opts.on('--server_host SERVER_HOST', 'server hostname') do |v|
|
202
|
-
args.host = v
|
203
|
-
end
|
204
|
-
opts.on('--server_port SERVER_PORT', 'server port') do |v|
|
205
|
-
args.port = v
|
206
|
-
end
|
207
|
-
|
208
|
-
# instance_methods(false) gives only the methods defined in that class.
|
209
|
-
scenes = NamedActions.instance_methods(false).map { |t| t.to_s }
|
210
|
-
scene_list = scenes.join(',')
|
211
|
-
opts.on("--action CODE", scenes, {}, 'pick a demo action',
|
212
|
-
" (#{scene_list})") do |v|
|
213
|
-
args.action = v
|
214
|
-
end
|
215
|
-
|
216
|
-
# Set the remaining values.
|
217
|
-
%w(project_id topic_name sub_name).each do |o|
|
218
|
-
opts.on("--#{o} VALUE", "#{o}") do |v|
|
219
|
-
args[o] = v
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end.parse!
|
223
|
-
_check_args(args)
|
224
|
-
end
|
225
|
-
|
226
|
-
def _check_args(args)
|
227
|
-
%w(host port action).each do |a|
|
228
|
-
if args[a].nil?
|
229
|
-
raise OptionParser::MissingArgument.new("please specify --#{a}")
|
230
|
-
end
|
231
|
-
end
|
232
|
-
args
|
233
|
-
end
|
234
|
-
|
235
|
-
def main
|
236
|
-
args = parse_args
|
237
|
-
pub, sub = publisher_stub(args), subscriber_stub(args)
|
238
|
-
NamedActions.new(pub, sub, args).method(args.action).call
|
239
|
-
end
|
240
|
-
|
241
|
-
main
|
@@ -1,159 +0,0 @@
|
|
1
|
-
# Copyright 2015 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
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
16
|
-
# source: tech/pubsub/proto/pubsub.proto
|
17
|
-
|
18
|
-
require 'google/protobuf'
|
19
|
-
|
20
|
-
require 'google/protobuf/empty'
|
21
|
-
Google::Protobuf::DescriptorPool.generated_pool.build do
|
22
|
-
add_message "tech.pubsub.Topic" do
|
23
|
-
optional :name, :string, 1
|
24
|
-
end
|
25
|
-
add_message "tech.pubsub.PubsubMessage" do
|
26
|
-
optional :data, :string, 1
|
27
|
-
optional :message_id, :string, 3
|
28
|
-
end
|
29
|
-
add_message "tech.pubsub.GetTopicRequest" do
|
30
|
-
optional :topic, :string, 1
|
31
|
-
end
|
32
|
-
add_message "tech.pubsub.PublishRequest" do
|
33
|
-
optional :topic, :string, 1
|
34
|
-
optional :message, :message, 2, "tech.pubsub.PubsubMessage"
|
35
|
-
end
|
36
|
-
add_message "tech.pubsub.PublishBatchRequest" do
|
37
|
-
optional :topic, :string, 1
|
38
|
-
repeated :messages, :message, 2, "tech.pubsub.PubsubMessage"
|
39
|
-
end
|
40
|
-
add_message "tech.pubsub.PublishBatchResponse" do
|
41
|
-
repeated :message_ids, :string, 1
|
42
|
-
end
|
43
|
-
add_message "tech.pubsub.ListTopicsRequest" do
|
44
|
-
optional :query, :string, 1
|
45
|
-
optional :max_results, :int32, 2
|
46
|
-
optional :page_token, :string, 3
|
47
|
-
end
|
48
|
-
add_message "tech.pubsub.ListTopicsResponse" do
|
49
|
-
repeated :topic, :message, 1, "tech.pubsub.Topic"
|
50
|
-
optional :next_page_token, :string, 2
|
51
|
-
end
|
52
|
-
add_message "tech.pubsub.DeleteTopicRequest" do
|
53
|
-
optional :topic, :string, 1
|
54
|
-
end
|
55
|
-
add_message "tech.pubsub.Subscription" do
|
56
|
-
optional :name, :string, 1
|
57
|
-
optional :topic, :string, 2
|
58
|
-
optional :query, :string, 3
|
59
|
-
optional :truncation_policy, :message, 4, "tech.pubsub.Subscription.TruncationPolicy"
|
60
|
-
optional :push_config, :message, 5, "tech.pubsub.PushConfig"
|
61
|
-
optional :ack_deadline_seconds, :int32, 6
|
62
|
-
optional :garbage_collect_seconds, :int64, 7
|
63
|
-
end
|
64
|
-
add_message "tech.pubsub.Subscription.TruncationPolicy" do
|
65
|
-
optional :max_bytes, :int64, 1
|
66
|
-
optional :max_age_seconds, :int64, 2
|
67
|
-
end
|
68
|
-
add_message "tech.pubsub.PushConfig" do
|
69
|
-
optional :push_endpoint, :string, 1
|
70
|
-
end
|
71
|
-
add_message "tech.pubsub.PubsubEvent" do
|
72
|
-
optional :subscription, :string, 1
|
73
|
-
optional :message, :message, 2, "tech.pubsub.PubsubMessage"
|
74
|
-
optional :truncated, :bool, 3
|
75
|
-
optional :deleted, :bool, 4
|
76
|
-
end
|
77
|
-
add_message "tech.pubsub.GetSubscriptionRequest" do
|
78
|
-
optional :subscription, :string, 1
|
79
|
-
end
|
80
|
-
add_message "tech.pubsub.ListSubscriptionsRequest" do
|
81
|
-
optional :query, :string, 1
|
82
|
-
optional :max_results, :int32, 3
|
83
|
-
optional :page_token, :string, 4
|
84
|
-
end
|
85
|
-
add_message "tech.pubsub.ListSubscriptionsResponse" do
|
86
|
-
repeated :subscription, :message, 1, "tech.pubsub.Subscription"
|
87
|
-
optional :next_page_token, :string, 2
|
88
|
-
end
|
89
|
-
add_message "tech.pubsub.TruncateSubscriptionRequest" do
|
90
|
-
optional :subscription, :string, 1
|
91
|
-
end
|
92
|
-
add_message "tech.pubsub.DeleteSubscriptionRequest" do
|
93
|
-
optional :subscription, :string, 1
|
94
|
-
end
|
95
|
-
add_message "tech.pubsub.ModifyPushConfigRequest" do
|
96
|
-
optional :subscription, :string, 1
|
97
|
-
optional :push_config, :message, 2, "tech.pubsub.PushConfig"
|
98
|
-
end
|
99
|
-
add_message "tech.pubsub.PullRequest" do
|
100
|
-
optional :subscription, :string, 1
|
101
|
-
optional :return_immediately, :bool, 2
|
102
|
-
end
|
103
|
-
add_message "tech.pubsub.PullResponse" do
|
104
|
-
optional :ack_id, :string, 1
|
105
|
-
optional :pubsub_event, :message, 2, "tech.pubsub.PubsubEvent"
|
106
|
-
end
|
107
|
-
add_message "tech.pubsub.PullBatchRequest" do
|
108
|
-
optional :subscription, :string, 1
|
109
|
-
optional :return_immediately, :bool, 2
|
110
|
-
optional :max_events, :int32, 3
|
111
|
-
end
|
112
|
-
add_message "tech.pubsub.PullBatchResponse" do
|
113
|
-
repeated :pull_responses, :message, 2, "tech.pubsub.PullResponse"
|
114
|
-
end
|
115
|
-
add_message "tech.pubsub.ModifyAckDeadlineRequest" do
|
116
|
-
optional :subscription, :string, 1
|
117
|
-
optional :ack_id, :string, 2
|
118
|
-
optional :ack_deadline_seconds, :int32, 3
|
119
|
-
end
|
120
|
-
add_message "tech.pubsub.AcknowledgeRequest" do
|
121
|
-
optional :subscription, :string, 1
|
122
|
-
repeated :ack_id, :string, 2
|
123
|
-
end
|
124
|
-
add_message "tech.pubsub.NackRequest" do
|
125
|
-
optional :subscription, :string, 1
|
126
|
-
repeated :ack_id, :string, 2
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
module Tech
|
131
|
-
module Pubsub
|
132
|
-
Topic = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.Topic").msgclass
|
133
|
-
PubsubMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PubsubMessage").msgclass
|
134
|
-
GetTopicRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.GetTopicRequest").msgclass
|
135
|
-
PublishRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PublishRequest").msgclass
|
136
|
-
PublishBatchRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PublishBatchRequest").msgclass
|
137
|
-
PublishBatchResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PublishBatchResponse").msgclass
|
138
|
-
ListTopicsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.ListTopicsRequest").msgclass
|
139
|
-
ListTopicsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.ListTopicsResponse").msgclass
|
140
|
-
DeleteTopicRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.DeleteTopicRequest").msgclass
|
141
|
-
Subscription = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.Subscription").msgclass
|
142
|
-
Subscription::TruncationPolicy = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.Subscription.TruncationPolicy").msgclass
|
143
|
-
PushConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PushConfig").msgclass
|
144
|
-
PubsubEvent = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PubsubEvent").msgclass
|
145
|
-
GetSubscriptionRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.GetSubscriptionRequest").msgclass
|
146
|
-
ListSubscriptionsRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.ListSubscriptionsRequest").msgclass
|
147
|
-
ListSubscriptionsResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.ListSubscriptionsResponse").msgclass
|
148
|
-
TruncateSubscriptionRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.TruncateSubscriptionRequest").msgclass
|
149
|
-
DeleteSubscriptionRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.DeleteSubscriptionRequest").msgclass
|
150
|
-
ModifyPushConfigRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.ModifyPushConfigRequest").msgclass
|
151
|
-
PullRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PullRequest").msgclass
|
152
|
-
PullResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PullResponse").msgclass
|
153
|
-
PullBatchRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PullBatchRequest").msgclass
|
154
|
-
PullBatchResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.PullBatchResponse").msgclass
|
155
|
-
ModifyAckDeadlineRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.ModifyAckDeadlineRequest").msgclass
|
156
|
-
AcknowledgeRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.AcknowledgeRequest").msgclass
|
157
|
-
NackRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("tech.pubsub.NackRequest").msgclass
|
158
|
-
end
|
159
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
# Copyright 2015 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
|
-
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
16
|
-
# Source: tech/pubsub/proto/pubsub.proto for package 'tech.pubsub'
|
17
|
-
|
18
|
-
require 'grpc'
|
19
|
-
require 'google/protobuf/empty'
|
20
|
-
require 'tech/pubsub/proto/pubsub'
|
21
|
-
|
22
|
-
module Tech
|
23
|
-
module Pubsub
|
24
|
-
module PublisherService
|
25
|
-
|
26
|
-
# TODO: add proto service documentation here
|
27
|
-
class Service
|
28
|
-
|
29
|
-
include GRPC::GenericService
|
30
|
-
|
31
|
-
self.marshal_class_method = :encode
|
32
|
-
self.unmarshal_class_method = :decode
|
33
|
-
self.service_name = 'tech.pubsub.PublisherService'
|
34
|
-
|
35
|
-
rpc :CreateTopic, Topic, Topic
|
36
|
-
rpc :Publish, PublishRequest, Google::Protobuf::Empty
|
37
|
-
rpc :PublishBatch, PublishBatchRequest, PublishBatchResponse
|
38
|
-
rpc :GetTopic, GetTopicRequest, Topic
|
39
|
-
rpc :ListTopics, ListTopicsRequest, ListTopicsResponse
|
40
|
-
rpc :DeleteTopic, DeleteTopicRequest, Google::Protobuf::Empty
|
41
|
-
end
|
42
|
-
|
43
|
-
Stub = Service.rpc_stub_class
|
44
|
-
end
|
45
|
-
module SubscriberService
|
46
|
-
|
47
|
-
# TODO: add proto service documentation here
|
48
|
-
class Service
|
49
|
-
|
50
|
-
include GRPC::GenericService
|
51
|
-
|
52
|
-
self.marshal_class_method = :encode
|
53
|
-
self.unmarshal_class_method = :decode
|
54
|
-
self.service_name = 'tech.pubsub.SubscriberService'
|
55
|
-
|
56
|
-
rpc :CreateSubscription, Subscription, Subscription
|
57
|
-
rpc :GetSubscription, GetSubscriptionRequest, Subscription
|
58
|
-
rpc :ListSubscriptions, ListSubscriptionsRequest, ListSubscriptionsResponse
|
59
|
-
rpc :DeleteSubscription, DeleteSubscriptionRequest, Google::Protobuf::Empty
|
60
|
-
rpc :TruncateSubscription, TruncateSubscriptionRequest, Google::Protobuf::Empty
|
61
|
-
rpc :ModifyPushConfig, ModifyPushConfigRequest, Google::Protobuf::Empty
|
62
|
-
rpc :Pull, PullRequest, PullResponse
|
63
|
-
rpc :PullBatch, PullBatchRequest, PullBatchResponse
|
64
|
-
rpc :ModifyAckDeadline, ModifyAckDeadlineRequest, Google::Protobuf::Empty
|
65
|
-
rpc :Acknowledge, AcknowledgeRequest, Google::Protobuf::Empty
|
66
|
-
rpc :Nack, NackRequest, Google::Protobuf::Empty
|
67
|
-
end
|
68
|
-
|
69
|
-
Stub = Service.rpc_stub_class
|
70
|
-
end
|
71
|
-
module PushEndpointService
|
72
|
-
|
73
|
-
# TODO: add proto service documentation here
|
74
|
-
class Service
|
75
|
-
|
76
|
-
include GRPC::GenericService
|
77
|
-
|
78
|
-
self.marshal_class_method = :encode
|
79
|
-
self.unmarshal_class_method = :decode
|
80
|
-
self.service_name = 'tech.pubsub.PushEndpointService'
|
81
|
-
|
82
|
-
rpc :HandlePubsubEvent, PubsubEvent, Google::Protobuf::Empty
|
83
|
-
end
|
84
|
-
|
85
|
-
Stub = Service.rpc_stub_class
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|