grpc 0.5.0

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.

Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +10 -0
  5. data/.rubocop_todo.yml +52 -0
  6. data/Gemfile +4 -0
  7. data/README.md +82 -0
  8. data/Rakefile +54 -0
  9. data/bin/apis/google/protobuf/empty.rb +44 -0
  10. data/bin/apis/pubsub_demo.rb +267 -0
  11. data/bin/apis/tech/pubsub/proto/pubsub.rb +174 -0
  12. data/bin/apis/tech/pubsub/proto/pubsub_services.rb +103 -0
  13. data/bin/interop/README.md +8 -0
  14. data/bin/interop/interop_client.rb +334 -0
  15. data/bin/interop/interop_server.rb +192 -0
  16. data/bin/interop/test/cpp/interop/empty.rb +44 -0
  17. data/bin/interop/test/cpp/interop/messages.rb +89 -0
  18. data/bin/interop/test/cpp/interop/test.rb +43 -0
  19. data/bin/interop/test/cpp/interop/test_services.rb +60 -0
  20. data/bin/math.proto +80 -0
  21. data/bin/math.rb +61 -0
  22. data/bin/math_client.rb +147 -0
  23. data/bin/math_server.rb +190 -0
  24. data/bin/math_services.rb +56 -0
  25. data/bin/noproto_client.rb +108 -0
  26. data/bin/noproto_server.rb +112 -0
  27. data/ext/grpc/extconf.rb +76 -0
  28. data/ext/grpc/rb_byte_buffer.c +241 -0
  29. data/ext/grpc/rb_byte_buffer.h +54 -0
  30. data/ext/grpc/rb_call.c +569 -0
  31. data/ext/grpc/rb_call.h +59 -0
  32. data/ext/grpc/rb_channel.c +264 -0
  33. data/ext/grpc/rb_channel.h +49 -0
  34. data/ext/grpc/rb_channel_args.c +154 -0
  35. data/ext/grpc/rb_channel_args.h +52 -0
  36. data/ext/grpc/rb_completion_queue.c +185 -0
  37. data/ext/grpc/rb_completion_queue.h +50 -0
  38. data/ext/grpc/rb_credentials.c +281 -0
  39. data/ext/grpc/rb_credentials.h +50 -0
  40. data/ext/grpc/rb_event.c +361 -0
  41. data/ext/grpc/rb_event.h +53 -0
  42. data/ext/grpc/rb_grpc.c +274 -0
  43. data/ext/grpc/rb_grpc.h +74 -0
  44. data/ext/grpc/rb_metadata.c +215 -0
  45. data/ext/grpc/rb_metadata.h +53 -0
  46. data/ext/grpc/rb_server.c +278 -0
  47. data/ext/grpc/rb_server.h +50 -0
  48. data/ext/grpc/rb_server_credentials.c +210 -0
  49. data/ext/grpc/rb_server_credentials.h +50 -0
  50. data/grpc.gemspec +41 -0
  51. data/lib/grpc.rb +39 -0
  52. data/lib/grpc/core/event.rb +44 -0
  53. data/lib/grpc/core/time_consts.rb +71 -0
  54. data/lib/grpc/errors.rb +61 -0
  55. data/lib/grpc/generic/active_call.rb +536 -0
  56. data/lib/grpc/generic/bidi_call.rb +221 -0
  57. data/lib/grpc/generic/client_stub.rb +413 -0
  58. data/lib/grpc/generic/rpc_desc.rb +150 -0
  59. data/lib/grpc/generic/rpc_server.rb +404 -0
  60. data/lib/grpc/generic/service.rb +235 -0
  61. data/lib/grpc/logconfig.rb +40 -0
  62. data/lib/grpc/version.rb +33 -0
  63. data/spec/alloc_spec.rb +44 -0
  64. data/spec/byte_buffer_spec.rb +67 -0
  65. data/spec/call_spec.rb +163 -0
  66. data/spec/channel_spec.rb +181 -0
  67. data/spec/client_server_spec.rb +372 -0
  68. data/spec/completion_queue_spec.rb +74 -0
  69. data/spec/credentials_spec.rb +71 -0
  70. data/spec/event_spec.rb +53 -0
  71. data/spec/generic/active_call_spec.rb +373 -0
  72. data/spec/generic/client_stub_spec.rb +519 -0
  73. data/spec/generic/rpc_desc_spec.rb +357 -0
  74. data/spec/generic/rpc_server_pool_spec.rb +139 -0
  75. data/spec/generic/rpc_server_spec.rb +404 -0
  76. data/spec/generic/service_spec.rb +342 -0
  77. data/spec/metadata_spec.rb +64 -0
  78. data/spec/server_credentials_spec.rb +69 -0
  79. data/spec/server_spec.rb +212 -0
  80. data/spec/spec_helper.rb +51 -0
  81. data/spec/testdata/README +1 -0
  82. data/spec/testdata/ca.pem +15 -0
  83. data/spec/testdata/server1.key +16 -0
  84. data/spec/testdata/server1.pem +16 -0
  85. data/spec/time_consts_spec.rb +89 -0
  86. metadata +353 -0
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2015, Google Inc.
4
+ # All rights reserved.
5
+ #
6
+ # Redistribution and use in source and binary forms, with or without
7
+ # modification, are permitted provided that the following conditions are
8
+ # met:
9
+ #
10
+ # * Redistributions of source code must retain the above copyright
11
+ # notice, this list of conditions and the following disclaimer.
12
+ # * Redistributions in binary form must reproduce the above
13
+ # copyright notice, this list of conditions and the following disclaimer
14
+ # in the documentation and/or other materials provided with the
15
+ # distribution.
16
+ # * Neither the name of Google Inc. nor the names of its
17
+ # contributors may be used to endorse or promote products derived from
18
+ # this software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
32
+ # interop_server is a Testing app that runs a gRPC interop testing server.
33
+ #
34
+ # It helps validate interoperation b/w gRPC in different environments
35
+ #
36
+ # Helps validate interoperation b/w different gRPC implementations.
37
+ #
38
+ # Usage: $ path/to/interop_server.rb --port
39
+
40
+ this_dir = File.expand_path(File.dirname(__FILE__))
41
+ lib_dir = File.join(File.dirname(File.dirname(this_dir)), 'lib')
42
+ $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
43
+ $LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir)
44
+
45
+ require 'forwardable'
46
+ require 'optparse'
47
+
48
+ require 'grpc'
49
+
50
+ require 'test/cpp/interop/test_services'
51
+ require 'test/cpp/interop/messages'
52
+ require 'test/cpp/interop/empty'
53
+
54
+ # loads the certificates by the test server.
55
+ def load_test_certs
56
+ this_dir = File.expand_path(File.dirname(__FILE__))
57
+ data_dir = File.join(File.dirname(File.dirname(this_dir)), 'spec/testdata')
58
+ files = ['ca.pem', 'server1.key', 'server1.pem']
59
+ files.map { |f| File.open(File.join(data_dir, f)).read }
60
+ end
61
+
62
+ # creates a ServerCredentials from the test certificates.
63
+ def test_server_creds
64
+ certs = load_test_certs
65
+ GRPC::Core::ServerCredentials.new(nil, certs[1], certs[2])
66
+ end
67
+
68
+ # produces a string of null chars (\0) of length l.
69
+ def nulls(l)
70
+ fail 'requires #{l} to be +ve' if l < 0
71
+ [].pack('x' * l).force_encoding('utf-8')
72
+ end
73
+
74
+ # A EnumeratorQueue wraps a Queue yielding the items added to it via each_item.
75
+ class EnumeratorQueue
76
+ extend Forwardable
77
+ def_delegators :@q, :push
78
+
79
+ def initialize(sentinel)
80
+ @q = Queue.new
81
+ @sentinel = sentinel
82
+ end
83
+
84
+ def each_item
85
+ return enum_for(:each_item) unless block_given?
86
+ loop do
87
+ r = @q.pop
88
+ break if r.equal?(@sentinel)
89
+ fail r if r.is_a? Exception
90
+ yield r
91
+ end
92
+ end
93
+ end
94
+
95
+ # A runnable implementation of the schema-specified testing service, with each
96
+ # service method implemented as required by the interop testing spec.
97
+ class TestTarget < Grpc::Testing::TestService::Service
98
+ include Grpc::Testing
99
+ include Grpc::Testing::PayloadType
100
+
101
+ def empty_call(_empty, _call)
102
+ Empty.new
103
+ end
104
+
105
+ def unary_call(simple_req, _call)
106
+ req_size = simple_req.response_size
107
+ SimpleResponse.new(payload: Payload.new(type: :COMPRESSABLE,
108
+ body: nulls(req_size)))
109
+ end
110
+
111
+ def streaming_input_call(call)
112
+ sizes = call.each_remote_read.map { |x| x.payload.body.length }
113
+ sum = sizes.inject { |s, x| s + x }
114
+ StreamingInputCallResponse.new(aggregated_payload_size: sum)
115
+ end
116
+
117
+ def streaming_output_call(req, _call)
118
+ cls = StreamingOutputCallResponse
119
+ req.response_parameters.map do |p|
120
+ cls.new(payload: Payload.new(type: req.response_type,
121
+ body: nulls(p.size)))
122
+ end
123
+ end
124
+
125
+ def full_duplex_call(reqs)
126
+ # reqs is a lazy Enumerator of the requests sent by the client.
127
+ q = EnumeratorQueue.new(self)
128
+ cls = StreamingOutputCallResponse
129
+ Thread.new do
130
+ begin
131
+ reqs.each do |req|
132
+ logger.info("read #{req.inspect}")
133
+ resp_size = req.response_parameters[0].size
134
+ resp = cls.new(payload: Payload.new(type: req.response_type,
135
+ body: nulls(resp_size)))
136
+ q.push(resp)
137
+ end
138
+ logger.info('finished reads')
139
+ q.push(self)
140
+ rescue StandardError => e
141
+ q.push(e) # share the exception with the enumerator
142
+ end
143
+ end
144
+ q.each_item
145
+ end
146
+
147
+ def half_duplex_call(reqs)
148
+ # TODO: update with unique behaviour of the half_duplex_call if that's
149
+ # ever required by any of the tests.
150
+ full_duplex_call(reqs)
151
+ end
152
+ end
153
+
154
+ # validates the the command line options, returning them as a Hash.
155
+ def parse_options
156
+ options = {
157
+ 'port' => nil,
158
+ 'secure' => false
159
+ }
160
+ OptionParser.new do |opts|
161
+ opts.banner = 'Usage: --port port'
162
+ opts.on('--port PORT', 'server port') do |v|
163
+ options['port'] = v
164
+ end
165
+ opts.on('-s', '--use_tls', 'require a secure connection?') do |v|
166
+ options['secure'] = v
167
+ end
168
+ end.parse!
169
+
170
+ if options['port'].nil?
171
+ fail(OptionParser::MissingArgument, 'please specify --port')
172
+ end
173
+ options
174
+ end
175
+
176
+ def main
177
+ opts = parse_options
178
+ host = "0.0.0.0:#{opts['port']}"
179
+ if opts['secure']
180
+ s = GRPC::RpcServer.new(creds: test_server_creds)
181
+ s.add_http2_port(host, true)
182
+ logger.info("... running securely on #{host}")
183
+ else
184
+ s = GRPC::RpcServer.new
185
+ s.add_http2_port(host)
186
+ logger.info("... running insecurely on #{host}")
187
+ end
188
+ s.handle(TestTarget)
189
+ s.run
190
+ end
191
+
192
+ main
@@ -0,0 +1,44 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
31
+ # source: test/cpp/interop/empty.proto
32
+
33
+ require 'google/protobuf'
34
+
35
+ Google::Protobuf::DescriptorPool.generated_pool.build do
36
+ add_message "grpc.testing.Empty" do
37
+ end
38
+ end
39
+
40
+ module Grpc
41
+ module Testing
42
+ Empty = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Empty").msgclass
43
+ end
44
+ end
@@ -0,0 +1,89 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
31
+ # source: test/cpp/interop/messages.proto
32
+
33
+ require 'google/protobuf'
34
+
35
+ Google::Protobuf::DescriptorPool.generated_pool.build do
36
+ add_message "grpc.testing.Payload" do
37
+ optional :type, :enum, 1, "grpc.testing.PayloadType"
38
+ optional :body, :string, 2
39
+ end
40
+ add_message "grpc.testing.SimpleRequest" do
41
+ optional :response_type, :enum, 1, "grpc.testing.PayloadType"
42
+ optional :response_size, :int32, 2
43
+ optional :payload, :message, 3, "grpc.testing.Payload"
44
+ optional :fill_username, :bool, 4
45
+ optional :fill_oauth_scope, :bool, 5
46
+ end
47
+ add_message "grpc.testing.SimpleResponse" do
48
+ optional :payload, :message, 1, "grpc.testing.Payload"
49
+ optional :username, :string, 2
50
+ optional :oauth_scope, :string, 3
51
+ end
52
+ add_message "grpc.testing.StreamingInputCallRequest" do
53
+ optional :payload, :message, 1, "grpc.testing.Payload"
54
+ end
55
+ add_message "grpc.testing.StreamingInputCallResponse" do
56
+ optional :aggregated_payload_size, :int32, 1
57
+ end
58
+ add_message "grpc.testing.ResponseParameters" do
59
+ optional :size, :int32, 1
60
+ optional :interval_us, :int32, 2
61
+ end
62
+ add_message "grpc.testing.StreamingOutputCallRequest" do
63
+ optional :response_type, :enum, 1, "grpc.testing.PayloadType"
64
+ repeated :response_parameters, :message, 2, "grpc.testing.ResponseParameters"
65
+ optional :payload, :message, 3, "grpc.testing.Payload"
66
+ end
67
+ add_message "grpc.testing.StreamingOutputCallResponse" do
68
+ optional :payload, :message, 1, "grpc.testing.Payload"
69
+ end
70
+ add_enum "grpc.testing.PayloadType" do
71
+ value :COMPRESSABLE, 0
72
+ value :UNCOMPRESSABLE, 1
73
+ value :RANDOM, 2
74
+ end
75
+ end
76
+
77
+ module Grpc
78
+ module Testing
79
+ Payload = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Payload").msgclass
80
+ SimpleRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.SimpleRequest").msgclass
81
+ SimpleResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.SimpleResponse").msgclass
82
+ StreamingInputCallRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingInputCallRequest").msgclass
83
+ StreamingInputCallResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingInputCallResponse").msgclass
84
+ ResponseParameters = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ResponseParameters").msgclass
85
+ StreamingOutputCallRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingOutputCallRequest").msgclass
86
+ StreamingOutputCallResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingOutputCallResponse").msgclass
87
+ PayloadType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.PayloadType").enummodule
88
+ end
89
+ end
@@ -0,0 +1,43 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
31
+ # source: test/cpp/interop/test.proto
32
+
33
+ require 'google/protobuf'
34
+
35
+ require 'test/cpp/interop/empty'
36
+ require 'test/cpp/interop/messages'
37
+ Google::Protobuf::DescriptorPool.generated_pool.build do
38
+ end
39
+
40
+ module Grpc
41
+ module Testing
42
+ end
43
+ end
@@ -0,0 +1,60 @@
1
+ # Copyright 2015, Google Inc.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following disclaimer
12
+ # in the documentation and/or other materials provided with the
13
+ # distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived from
16
+ # this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
31
+ # Source: test/cpp/interop/test.proto for package 'grpc.testing'
32
+
33
+ require 'grpc'
34
+ require 'test/cpp/interop/test'
35
+
36
+ module Grpc
37
+ module Testing
38
+ module TestService
39
+
40
+ # TODO: add proto service documentation here
41
+ class Service
42
+
43
+ include GRPC::GenericService
44
+
45
+ self.marshal_class_method = :encode
46
+ self.unmarshal_class_method = :decode
47
+ self.service_name = 'grpc.testing.TestService'
48
+
49
+ rpc :EmptyCall, Empty, Empty
50
+ rpc :UnaryCall, SimpleRequest, SimpleResponse
51
+ rpc :StreamingOutputCall, StreamingOutputCallRequest, stream(StreamingOutputCallResponse)
52
+ rpc :StreamingInputCall, stream(StreamingInputCallRequest), StreamingInputCallResponse
53
+ rpc :FullDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse)
54
+ rpc :HalfDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse)
55
+ end
56
+
57
+ Stub = Service.rpc_stub_class
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,80 @@
1
+
2
+ // Copyright 2015, Google Inc.
3
+ // All rights reserved.
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without
6
+ // modification, are permitted provided that the following conditions are
7
+ // met:
8
+ //
9
+ // * Redistributions of source code must retain the above copyright
10
+ // notice, this list of conditions and the following disclaimer.
11
+ // * Redistributions in binary form must reproduce the above
12
+ // copyright notice, this list of conditions and the following disclaimer
13
+ // in the documentation and/or other materials provided with the
14
+ // distribution.
15
+ // * Neither the name of Google Inc. nor the names of its
16
+ // contributors may be used to endorse or promote products derived from
17
+ // this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ syntax = "proto3";
32
+
33
+ package math;
34
+
35
+ message DivArgs {
36
+ optional int64 dividend = 1;
37
+ optional int64 divisor = 2;
38
+ }
39
+
40
+ message DivReply {
41
+ optional int64 quotient = 1;
42
+ optional int64 remainder = 2;
43
+ }
44
+
45
+ message FibArgs {
46
+ optional int64 limit = 1;
47
+ }
48
+
49
+ message Num {
50
+ optional int64 num = 1;
51
+ }
52
+
53
+ message FibReply {
54
+ optional int64 count = 1;
55
+ }
56
+
57
+ service Math {
58
+ // Div divides args.dividend by args.divisor and returns the quotient and
59
+ // remainder.
60
+ rpc Div (DivArgs) returns (DivReply) {
61
+ }
62
+
63
+ // DivMany accepts an arbitrary number of division args from the client stream
64
+ // and sends back the results in the reply stream. The stream continues until
65
+ // the client closes its end; the server does the same after sending all the
66
+ // replies. The stream ends immediately if either end aborts.
67
+ rpc DivMany (stream DivArgs) returns (stream DivReply) {
68
+ }
69
+
70
+ // Fib generates numbers in the Fibonacci sequence. If args.limit > 0, Fib
71
+ // generates up to limit numbers; otherwise it continues until the call is
72
+ // canceled. Unlike Fib above, Fib has no final FibReply.
73
+ rpc Fib (FibArgs) returns (stream Num) {
74
+ }
75
+
76
+ // Sum sums a stream of numbers, returning the final result once the stream
77
+ // is closed.
78
+ rpc Sum (stream Num) returns (Num) {
79
+ }
80
+ }