upfluence-thrift 2.6.8 → 2.7.4
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/benchmark/{gen-rb/benchmark_constants.rb → benchmark_constants.rb} +1 -1
- data/benchmark/{gen-rb/benchmark_service.rb → benchmark_service.rb} +2 -2
- data/benchmark/{gen-rb/benchmark_types.rb → benchmark_types.rb} +1 -1
- data/ext/struct.c +5 -1
- data/lib/thrift/base_stream.rb +85 -0
- data/lib/thrift/bidi_stream.rb +183 -0
- data/lib/thrift/client.rb +84 -17
- data/lib/thrift/inbound_stream.rb +72 -0
- data/lib/thrift/middleware.rb +42 -0
- data/lib/thrift/outbound_stream.rb +52 -0
- data/lib/thrift/processor.rb +287 -47
- data/lib/thrift/protocol/base_protocol.rb +35 -33
- data/lib/thrift/protocol/binary_protocol.rb +8 -1
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
- data/lib/thrift/protocol/compact_protocol.rb +8 -0
- data/lib/thrift/protocol/json_protocol.rb +21 -4
- data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
- data/lib/thrift/server/base_server.rb +8 -2
- data/lib/thrift/server/nonblocking_server.rb +5 -4
- data/lib/thrift/server/simple_server.rb +5 -1
- data/lib/thrift/server/thread_pool_server.rb +5 -1
- data/lib/thrift/server/threaded_server.rb +5 -1
- data/lib/thrift/transport/base_server_transport.rb +1 -1
- data/lib/thrift/transport/base_transport.rb +8 -0
- data/lib/thrift/transport/buffered_transport.rb +9 -1
- data/lib/thrift/transport/framed_transport.rb +9 -1
- data/lib/thrift/transport/http_client_transport.rb +4 -0
- data/lib/thrift/transport/io_stream_transport.rb +4 -1
- data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
- data/lib/thrift/transport/server_socket.rb +5 -0
- data/lib/thrift/transport/socket.rb +21 -17
- data/lib/thrift/transport/ssl_server_socket.rb +41 -0
- data/lib/thrift/transport/ssl_socket.rb +51 -0
- data/lib/thrift/transport/unix_server_socket.rb +5 -1
- data/lib/thrift/transport/unix_socket.rb +5 -1
- data/lib/thrift/types/annotation/deprecation/deprecation_constants.rb +1 -1
- data/lib/thrift/types/annotation/deprecation/deprecation_types.rb +2 -2
- data/lib/thrift/types/annotation/exception/exception_constants.rb +17 -0
- data/lib/thrift/types/annotation/exception/exception_types.rb +44 -0
- data/lib/thrift/types/annotation/naming/naming_constants.rb +1 -1
- data/lib/thrift/types/annotation/naming/naming_types.rb +2 -2
- data/lib/thrift/types/annotation/rpc/rpc_constants.rb +17 -0
- data/lib/thrift/types/annotation/rpc/rpc_types.rb +74 -0
- data/lib/thrift/types/annotation_definition/annotation_definition_constants.rb +15 -0
- data/lib/thrift/types/annotation_definition/annotation_definition_types.rb +116 -0
- data/lib/thrift/types/constant_definition/constant_definition_constants.rb +15 -0
- data/lib/thrift/types/constant_definition/constant_definition_types.rb +292 -0
- data/lib/thrift/types/core/core_constants.rb +15 -0
- data/lib/thrift/types/core/core_types.rb +58 -0
- data/lib/thrift/types/enum_definition/enum_definition_constants.rb +15 -0
- data/lib/thrift/types/enum_definition/enum_definition_types.rb +106 -0
- data/lib/thrift/types/known/any/any_constants.rb +1 -1
- data/lib/thrift/types/known/any/any_types.rb +2 -2
- data/lib/thrift/types/known/duration/duration_constants.rb +1 -1
- data/lib/thrift/types/known/duration/duration_types.rb +2 -2
- data/lib/thrift/types/known/timestamp/timestamp_constants.rb +1 -1
- data/lib/thrift/types/known/timestamp/timestamp_types.rb +2 -2
- data/lib/thrift/types/plugin/plugin.rb +139 -0
- data/lib/thrift/types/plugin/plugin_constants.rb +15 -0
- data/lib/thrift/types/plugin/plugin_types.rb +106 -0
- data/lib/thrift/types/program_definition/program_definition_constants.rb +15 -0
- data/lib/thrift/types/program_definition/program_definition_types.rb +137 -0
- data/lib/thrift/types/service_definition/service_definition_constants.rb +15 -0
- data/lib/thrift/types/service_definition/service_definition_types.rb +160 -0
- data/lib/thrift/types/struct_definition/struct_definition_constants.rb +15 -0
- data/lib/thrift/types/struct_definition/struct_definition_types.rb +157 -0
- data/lib/thrift/types/type_definition/type_definition_constants.rb +15 -0
- data/lib/thrift/types/type_definition/type_definition_types.rb +242 -0
- data/lib/thrift/types/value/value_constants.rb +1 -1
- data/lib/thrift/types/value/value_types.rb +50 -51
- data/lib/thrift/types.rb +11 -3
- data/lib/thrift/union.rb +3 -6
- data/lib/thrift.rb +6 -0
- data/lib/types/annotation/deprecation/deprecation_constants.rb +16 -0
- data/lib/types/annotation/deprecation/deprecation_types.rb +42 -0
- data/lib/types/annotation/naming/naming_constants.rb +16 -0
- data/lib/types/annotation/naming/naming_types.rb +57 -0
- data/lib/types/annotation_definition/annotation_definition_constants.rb +14 -0
- data/lib/types/annotation_definition/annotation_definition_types.rb +114 -0
- data/lib/types/constant_definition/constant_definition_constants.rb +14 -0
- data/lib/types/constant_definition/constant_definition_types.rb +290 -0
- data/lib/types/core/core_constants.rb +14 -0
- data/lib/types/core/core_types.rb +56 -0
- data/lib/types/enum_definition/enum_definition_constants.rb +14 -0
- data/lib/types/enum_definition/enum_definition_types.rb +104 -0
- data/lib/types/known/any/any_constants.rb +16 -0
- data/lib/types/known/any/any_types.rb +59 -0
- data/lib/types/known/duration/duration_constants.rb +16 -0
- data/lib/types/known/duration/duration_types.rb +59 -0
- data/lib/types/known/timestamp/timestamp_constants.rb +16 -0
- data/lib/types/known/timestamp/timestamp_types.rb +59 -0
- data/lib/types/plugin/plugin.rb +137 -0
- data/lib/types/plugin/plugin_constants.rb +14 -0
- data/lib/types/plugin/plugin_types.rb +104 -0
- data/lib/types/program_definition/program_definition_constants.rb +14 -0
- data/lib/types/program_definition/program_definition_types.rb +135 -0
- data/lib/types/service_definition/service_definition_constants.rb +14 -0
- data/lib/types/service_definition/service_definition_types.rb +158 -0
- data/lib/types/struct_definition/struct_definition_constants.rb +14 -0
- data/lib/types/struct_definition/struct_definition_types.rb +155 -0
- data/lib/types/type_definition/type_definition_constants.rb +14 -0
- data/lib/types/type_definition/type_definition_types.rb +240 -0
- data/lib/types/value/value_constants.rb +14 -0
- data/lib/types/value/value_types.rb +330 -0
- data/spec/{gen-rb/base → base}/base_service.rb +2 -2
- data/spec/{gen-rb/base → base}/base_service_constants.rb +1 -1
- data/spec/{gen-rb/base → base}/base_service_types.rb +1 -1
- data/spec/base_protocol_spec.rb +79 -71
- data/spec/base_transport_spec.rb +155 -117
- data/spec/binary_protocol_accelerated_spec.rb +6 -2
- data/spec/binary_protocol_spec.rb +16 -8
- data/spec/binary_protocol_spec_shared.rb +77 -77
- data/spec/bytes_spec.rb +38 -38
- data/spec/client_spec.rb +48 -50
- data/spec/compact_protocol_spec.rb +59 -46
- data/spec/exception_spec.rb +54 -54
- data/spec/{gen-rb/extended → extended}/extended_service.rb +2 -2
- data/spec/{gen-rb/extended → extended}/extended_service_constants.rb +1 -1
- data/spec/{gen-rb/extended → extended}/extended_service_types.rb +1 -1
- data/spec/flat_spec.rb +5 -5
- data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +4 -4
- data/spec/gen-rb/flat/referenced_constants.rb +1 -1
- data/spec/gen-rb/flat/referenced_types.rb +1 -1
- data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +1 -1
- data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +1 -1
- data/spec/http_client_spec.rb +96 -43
- data/spec/json_protocol_spec.rb +170 -131
- data/spec/namespaced_spec.rb +24 -27
- data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/namespaced_nonblocking_service.rb +4 -4
- data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/thrift_namespaced_spec_constants.rb +1 -1
- data/spec/{gen-rb/namespaced_spec_namespace → namespaced_spec_namespace}/thrift_namespaced_spec_types.rb +1 -1
- data/spec/nonblocking_server_spec.rb +16 -16
- data/spec/{gen-rb/nonblocking_service.rb → nonblocking_service.rb} +4 -4
- data/spec/{gen-rb/other_namespace → other_namespace}/referenced_constants.rb +1 -1
- data/spec/{gen-rb/other_namespace → other_namespace}/referenced_types.rb +1 -1
- data/spec/processor_spec.rb +42 -31
- data/spec/rack_application_spec.rb +22 -26
- data/spec/serializer_spec.rb +20 -20
- data/spec/server_socket_spec.rb +27 -22
- data/spec/server_spec.rb +91 -51
- data/spec/socket_spec.rb +23 -16
- data/spec/socket_spec_shared.rb +31 -31
- data/spec/spec_helper.rb +1 -1
- data/spec/ssl_server_socket_spec.rb +34 -0
- data/spec/ssl_socket_spec.rb +78 -0
- data/spec/streaming_spec.rb +442 -0
- data/spec/struct_nested_containers_spec.rb +24 -24
- data/spec/struct_spec.rb +120 -120
- data/spec/thin_http_server_spec.rb +71 -28
- data/spec/{gen-rb/thrift_spec_constants.rb → thrift_spec_constants.rb} +1 -1
- data/spec/{gen-rb/thrift_spec_types.rb → thrift_spec_types.rb} +16 -16
- data/spec/types/known/any_spec.rb +2 -2
- data/spec/types/known/duration_spec.rb +1 -1
- data/spec/types/known/timestamp_spec.rb +1 -1
- data/spec/types/value_spec.rb +2 -1
- data/spec/types_spec.rb +56 -53
- data/spec/union_spec.rb +51 -40
- data/spec/unix_socket_spec.rb +43 -34
- data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +267 -260
- data/test/debug_proto/gen-rb/debug_proto_test_types.rb +1481 -1416
- data/test/debug_proto/gen-rb/empty_service.rb +31 -27
- data/test/debug_proto/gen-rb/inherited.rb +102 -98
- data/test/debug_proto/gen-rb/reverse_order_service.rb +112 -108
- data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +99 -95
- data/test/debug_proto/gen-rb/srv.rb +525 -406
- metadata +178 -41
data/spec/namespaced_spec.rb
CHANGED
|
@@ -24,44 +24,41 @@ describe 'namespaced generation' do
|
|
|
24
24
|
require 'namespaced_spec_namespace/namespaced_nonblocking_service'
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
it
|
|
28
|
-
prefix = File.expand_path(
|
|
29
|
-
[
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
File.exist?(File.join(prefix, name)).should be_true
|
|
27
|
+
it 'generated the right files' do
|
|
28
|
+
prefix = File.expand_path('gen-rb/flat', __dir__)
|
|
29
|
+
['namespaced_nonblocking_service.rb',
|
|
30
|
+
'thrift_namespaced_spec_constants.rb',
|
|
31
|
+
'thrift_namespaced_spec_types.rb',
|
|
32
|
+
'referenced_constants.rb',
|
|
33
|
+
'referenced_types.rb'].each do |name|
|
|
34
|
+
expect(File.exist?(File.join(prefix, name))).to be_truthy
|
|
36
35
|
end
|
|
37
36
|
end
|
|
38
37
|
|
|
39
|
-
it
|
|
40
|
-
prefix = File.expand_path(
|
|
41
|
-
[
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
File.exist?(File.join(prefix, name)).should_not be_true
|
|
38
|
+
it 'did not generate the wrong files' do
|
|
39
|
+
prefix = File.expand_path('gen-rb/flat', __dir__)
|
|
40
|
+
['namespaced_spec_namespace/namespaced_nonblocking_service.rb',
|
|
41
|
+
'namespaced_spec_namespace/thrift_namespaced_spec_constants.rb',
|
|
42
|
+
'namespaced_spec_namespace/thrift_namespaced_spec_types.rb',
|
|
43
|
+
'other_namespace/referenced_constants.rb',
|
|
44
|
+
'other_namespace/referenced_types.rb'].each do |name|
|
|
45
|
+
expect(File.exist?(File.join(prefix, name))).not_to be_truthy
|
|
48
46
|
end
|
|
49
47
|
end
|
|
50
48
|
|
|
51
|
-
it
|
|
52
|
-
defined?(NamespacedSpecNamespace::NamespacedNonblockingService).
|
|
49
|
+
it 'has a service class in the right place' do
|
|
50
|
+
expect(defined?(NamespacedSpecNamespace::NamespacedNonblockingService)).to be_truthy
|
|
53
51
|
end
|
|
54
52
|
|
|
55
|
-
it
|
|
56
|
-
defined?(NamespacedSpecNamespace::Hello).
|
|
53
|
+
it 'has a struct in the right place' do
|
|
54
|
+
expect(defined?(NamespacedSpecNamespace::Hello)).to be_truthy
|
|
57
55
|
end
|
|
58
56
|
|
|
59
|
-
it
|
|
60
|
-
defined?(OtherNamespace::SomeEnum).
|
|
57
|
+
it 'required an included file' do
|
|
58
|
+
expect(defined?(OtherNamespace::SomeEnum)).to be_truthy
|
|
61
59
|
end
|
|
62
60
|
|
|
63
|
-
it
|
|
64
|
-
require
|
|
61
|
+
it 'extended a service' do
|
|
62
|
+
require 'extended/extended_service'
|
|
65
63
|
end
|
|
66
|
-
|
|
67
64
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Autogenerated by Thrift Compiler ()
|
|
2
|
+
# Autogenerated by Thrift Compiler (v0.0.1-upfluence)
|
|
3
3
|
#
|
|
4
4
|
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
5
|
#
|
|
@@ -412,11 +412,11 @@ module NamespacedSpecNamespace
|
|
|
412
412
|
].freeze
|
|
413
413
|
|
|
414
414
|
METHODS = {
|
|
415
|
-
'greeting' => { args_klass: Greeting_args, oneway: false, legacy_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS},
|
|
416
|
-
'block' => { args_klass: Block_args, oneway: false, legacy_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS},
|
|
415
|
+
'greeting' => { args_klass: Greeting_args, result_klass: Greeting_result, oneway: false, legacy_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS},
|
|
416
|
+
'block' => { args_klass: Block_args, result_klass: Block_result, oneway: false, legacy_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS},
|
|
417
417
|
'unblock' => { args_klass: Unblock_args, oneway: true, legacy_annotations: THRIFT_METHOD_UNBLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_UNBLOCK_STRUCTURED_ANNOTATIONS},
|
|
418
418
|
'shutdown' => { args_klass: Shutdown_args, oneway: true, legacy_annotations: THRIFT_METHOD_SHUTDOWN_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SHUTDOWN_STRUCTURED_ANNOTATIONS},
|
|
419
|
-
'sleep' => { args_klass: Sleep_args, oneway: false, legacy_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS},
|
|
419
|
+
'sleep' => { args_klass: Sleep_args, result_klass: Sleep_result, oneway: false, legacy_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS},
|
|
420
420
|
}.freeze
|
|
421
421
|
|
|
422
422
|
def execute_greeting(args)
|
|
@@ -176,8 +176,8 @@ describe 'NonblockingServer' do
|
|
|
176
176
|
|
|
177
177
|
it "should handle basic message passing" do
|
|
178
178
|
client = setup_client
|
|
179
|
-
client.greeting(true).
|
|
180
|
-
client.greeting(false).
|
|
179
|
+
expect(client.greeting(true)).to eq(SpecNamespace::Hello.new)
|
|
180
|
+
expect(client.greeting(false)).to eq(SpecNamespace::Hello.new(:greeting => 'Aloha!'))
|
|
181
181
|
@server.shutdown
|
|
182
182
|
end
|
|
183
183
|
|
|
@@ -195,7 +195,7 @@ describe 'NonblockingServer' do
|
|
|
195
195
|
end
|
|
196
196
|
4.times { trans_queue.pop }
|
|
197
197
|
setup_client.unblock(4)
|
|
198
|
-
4.times { queue.pop.
|
|
198
|
+
4.times { expect(queue.pop).to be_truthy }
|
|
199
199
|
@server.shutdown
|
|
200
200
|
end
|
|
201
201
|
|
|
@@ -212,15 +212,15 @@ describe 'NonblockingServer' do
|
|
|
212
212
|
queues[4] << :hello
|
|
213
213
|
queues[5] << :hello
|
|
214
214
|
queues[6] << :hello
|
|
215
|
-
3.times { result.pop.
|
|
216
|
-
client.greeting(true).
|
|
215
|
+
3.times { expect(result.pop).to eq(SpecNamespace::Hello.new) }
|
|
216
|
+
expect(client.greeting(true)).to eq(SpecNamespace::Hello.new)
|
|
217
217
|
queues[5] << [:unblock, 4]
|
|
218
|
-
4.times { result.pop.
|
|
218
|
+
4.times { expect(result.pop).to be_truthy }
|
|
219
219
|
queues[2] << :hello
|
|
220
|
-
result.pop.
|
|
221
|
-
client.greeting(false).
|
|
220
|
+
expect(result.pop).to eq(SpecNamespace::Hello.new)
|
|
221
|
+
expect(client.greeting(false)).to eq(SpecNamespace::Hello.new(:greeting => 'Aloha!'))
|
|
222
222
|
7.times { queues.shift << :exit }
|
|
223
|
-
client.greeting(true).
|
|
223
|
+
expect(client.greeting(true)).to eq(SpecNamespace::Hello.new)
|
|
224
224
|
@server.shutdown
|
|
225
225
|
end
|
|
226
226
|
|
|
@@ -229,7 +229,7 @@ describe 'NonblockingServer' do
|
|
|
229
229
|
client = setup_client
|
|
230
230
|
client.greeting(false) # force a message pass
|
|
231
231
|
@server.shutdown
|
|
232
|
-
@server_thread.join(2).
|
|
232
|
+
expect(@server_thread.join(2)).to be_an_instance_of(Thread)
|
|
233
233
|
end
|
|
234
234
|
|
|
235
235
|
it "should continue processing active messages when shutting down" do
|
|
@@ -238,8 +238,8 @@ describe 'NonblockingServer' do
|
|
|
238
238
|
client << :sleep
|
|
239
239
|
sleep 0.1 # give the server time to start processing the client's message
|
|
240
240
|
@server.shutdown
|
|
241
|
-
@server_thread.join(2).
|
|
242
|
-
result.pop.
|
|
241
|
+
expect(@server_thread.join(2)).to be_an_instance_of(Thread)
|
|
242
|
+
expect(result.pop).to eq(:slept)
|
|
243
243
|
end
|
|
244
244
|
|
|
245
245
|
it "should kill active messages when they don't expire while shutting down" do
|
|
@@ -249,15 +249,15 @@ describe 'NonblockingServer' do
|
|
|
249
249
|
sleep 0.1 # start processing the client's message
|
|
250
250
|
@server.shutdown(1)
|
|
251
251
|
@catch_exceptions = true
|
|
252
|
-
@server_thread.join(3).
|
|
253
|
-
result.
|
|
252
|
+
expect(@server_thread.join(3)).not_to be_nil
|
|
253
|
+
expect(result).to be_empty
|
|
254
254
|
end
|
|
255
255
|
|
|
256
256
|
it "should allow shutting down in response to a message" do
|
|
257
257
|
client = setup_client
|
|
258
|
-
client.greeting(true).
|
|
258
|
+
expect(client.greeting(true)).to eq(SpecNamespace::Hello.new)
|
|
259
259
|
client.shutdown
|
|
260
|
-
@server_thread.join(2).
|
|
260
|
+
expect(@server_thread.join(2)).not_to be_nil
|
|
261
261
|
end
|
|
262
262
|
end
|
|
263
263
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Autogenerated by Thrift Compiler ()
|
|
2
|
+
# Autogenerated by Thrift Compiler (v0.0.1-upfluence)
|
|
3
3
|
#
|
|
4
4
|
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
5
|
#
|
|
@@ -412,11 +412,11 @@ module SpecNamespace
|
|
|
412
412
|
].freeze
|
|
413
413
|
|
|
414
414
|
METHODS = {
|
|
415
|
-
'greeting' => { args_klass: Greeting_args, oneway: false, legacy_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS},
|
|
416
|
-
'block' => { args_klass: Block_args, oneway: false, legacy_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS},
|
|
415
|
+
'greeting' => { args_klass: Greeting_args, result_klass: Greeting_result, oneway: false, legacy_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_GREETING_STRUCTURED_ANNOTATIONS},
|
|
416
|
+
'block' => { args_klass: Block_args, result_klass: Block_result, oneway: false, legacy_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_BLOCK_STRUCTURED_ANNOTATIONS},
|
|
417
417
|
'unblock' => { args_klass: Unblock_args, oneway: true, legacy_annotations: THRIFT_METHOD_UNBLOCK_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_UNBLOCK_STRUCTURED_ANNOTATIONS},
|
|
418
418
|
'shutdown' => { args_klass: Shutdown_args, oneway: true, legacy_annotations: THRIFT_METHOD_SHUTDOWN_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SHUTDOWN_STRUCTURED_ANNOTATIONS},
|
|
419
|
-
'sleep' => { args_klass: Sleep_args, oneway: false, legacy_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS},
|
|
419
|
+
'sleep' => { args_klass: Sleep_args, result_klass: Sleep_result, oneway: false, legacy_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS, structured_annotations: THRIFT_METHOD_SLEEP_STRUCTURED_ANNOTATIONS},
|
|
420
420
|
}.freeze
|
|
421
421
|
|
|
422
422
|
def execute_greeting(args)
|
data/spec/processor_spec.rb
CHANGED
|
@@ -20,59 +20,70 @@
|
|
|
20
20
|
require 'spec_helper'
|
|
21
21
|
|
|
22
22
|
describe 'Processor' do
|
|
23
|
-
|
|
24
23
|
class ProcessorSpec
|
|
25
24
|
include Thrift::Processor
|
|
26
25
|
end
|
|
27
26
|
|
|
28
27
|
describe Thrift::Processor do
|
|
29
28
|
before(:each) do
|
|
30
|
-
@processor = ProcessorSpec.new(
|
|
31
|
-
@prot =
|
|
29
|
+
@processor = ProcessorSpec.new(double('MockHandler'))
|
|
30
|
+
@prot = double('MockProtocol')
|
|
32
31
|
end
|
|
33
32
|
|
|
34
33
|
def mock_trans(obj)
|
|
35
|
-
obj.
|
|
36
|
-
|
|
37
|
-
trans.
|
|
34
|
+
expect(obj).to receive(:trans).ordered do
|
|
35
|
+
double('trans').tap do |trans|
|
|
36
|
+
expect(trans).to receive(:flush).ordered
|
|
38
37
|
end
|
|
39
38
|
end
|
|
40
39
|
end
|
|
41
40
|
|
|
42
|
-
it
|
|
43
|
-
@prot.
|
|
44
|
-
@processor.
|
|
45
|
-
@processor.process(@prot, @prot).
|
|
41
|
+
it 'should call process_<message> when it receives that message' do
|
|
42
|
+
expect(@prot).to receive(:read_message_begin).ordered.and_return ['testMessage', Thrift::MessageTypes::CALL, 17]
|
|
43
|
+
expect(@processor).to receive(:process_testMessage).with(17, @prot, @prot).ordered
|
|
44
|
+
expect(@processor.process(@prot, @prot)).to eq(true)
|
|
46
45
|
end
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
@prot.
|
|
50
|
-
@prot.
|
|
51
|
-
@prot.
|
|
52
|
-
@prot.
|
|
53
|
-
e =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
it 'should raise an ApplicationException when the received message cannot be processed' do
|
|
48
|
+
expect(@prot).to receive(:read_message_begin).ordered.and_return ['testMessage', Thrift::MessageTypes::CALL, 4]
|
|
49
|
+
expect(@prot).to receive(:skip).with(Thrift::Types::STRUCT).ordered
|
|
50
|
+
expect(@prot).to receive(:read_message_end).ordered
|
|
51
|
+
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::EXCEPTION, 4).ordered
|
|
52
|
+
e = Thrift::ApplicationException.new(
|
|
53
|
+
Thrift::ApplicationException::UNKNOWN_METHOD,
|
|
54
|
+
'Unknown function testMessage'
|
|
55
|
+
)
|
|
56
|
+
expect(Thrift::ApplicationException).to receive(:new).with(Thrift::ApplicationException::UNKNOWN_METHOD,
|
|
57
|
+
'Unknown function testMessage').and_return(e)
|
|
58
|
+
expect(@prot).to receive(:write_struct_begin).with('Thrift::ApplicationException').ordered
|
|
59
|
+
expect(@prot).to receive(:write_field_begin).with('message', Thrift::Types::STRING, 1).ordered
|
|
60
|
+
expect(@prot).to receive(:write_string).with('Unknown function testMessage').ordered
|
|
61
|
+
expect(@prot).to receive(:write_field_end).ordered
|
|
62
|
+
expect(@prot).to receive(:write_field_begin).with('type', Thrift::Types::I32, 2).ordered
|
|
63
|
+
expect(@prot).to receive(:write_i32).with(Thrift::ApplicationException::UNKNOWN_METHOD).ordered
|
|
64
|
+
expect(@prot).to receive(:write_field_end).ordered
|
|
65
|
+
expect(@prot).to receive(:write_field_stop).ordered
|
|
66
|
+
expect(@prot).to receive(:write_struct_end).ordered
|
|
67
|
+
expect(@prot).to receive(:write_message_end).ordered
|
|
57
68
|
mock_trans(@prot)
|
|
58
69
|
@processor.process(@prot, @prot)
|
|
59
70
|
end
|
|
60
71
|
|
|
61
|
-
it
|
|
62
|
-
args_class =
|
|
63
|
-
args =
|
|
64
|
-
args.
|
|
72
|
+
it 'should pass args off to the args class' do
|
|
73
|
+
args_class = double('MockArgsClass')
|
|
74
|
+
args = double('#<MockArgsClass:mock>').tap do |args|
|
|
75
|
+
expect(args).to receive(:read).with(@prot).ordered
|
|
65
76
|
end
|
|
66
|
-
args_class.
|
|
67
|
-
@prot.
|
|
68
|
-
@processor.read_args(@prot, args_class).
|
|
77
|
+
expect(args_class).to receive(:new).and_return args
|
|
78
|
+
expect(@prot).to receive(:read_message_end).ordered
|
|
79
|
+
expect(@processor.read_args(@prot, args_class)).to eql(args)
|
|
69
80
|
end
|
|
70
81
|
|
|
71
|
-
it
|
|
72
|
-
@prot.
|
|
73
|
-
result =
|
|
74
|
-
result.
|
|
75
|
-
@prot.
|
|
82
|
+
it 'should write out a reply when asked' do
|
|
83
|
+
expect(@prot).to receive(:write_message_begin).with('testMessage', Thrift::MessageTypes::REPLY, 23).ordered
|
|
84
|
+
result = double('MockResult')
|
|
85
|
+
expect(result).to receive(:write).with(@prot).ordered
|
|
86
|
+
expect(@prot).to receive(:write_message_end).ordered
|
|
76
87
|
mock_trans(@prot)
|
|
77
88
|
@processor.write_result(result, @prot, 'testMessage', 23)
|
|
78
89
|
end
|
|
@@ -25,53 +25,49 @@ require 'thrift/server/rack_application'
|
|
|
25
25
|
describe Thrift::RackApplication do
|
|
26
26
|
include Rack::Test::Methods
|
|
27
27
|
|
|
28
|
-
let(:processor) {
|
|
29
|
-
let(:protocol_factory) {
|
|
28
|
+
let(:processor) { double('processor') }
|
|
29
|
+
let(:protocol_factory) { double('protocol factory') }
|
|
30
30
|
|
|
31
31
|
def app
|
|
32
|
-
Thrift::RackApplication.for(
|
|
32
|
+
Thrift::RackApplication.for('/', processor, protocol_factory)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
context
|
|
36
|
-
|
|
35
|
+
context '404 response' do
|
|
37
36
|
it 'receives a non-POST' do
|
|
38
|
-
header('Content-Type',
|
|
39
|
-
get
|
|
40
|
-
last_response.status.
|
|
37
|
+
header('Content-Type', 'application/x-thrift')
|
|
38
|
+
get '/'
|
|
39
|
+
expect(last_response.status).to be 404
|
|
41
40
|
end
|
|
42
41
|
|
|
43
42
|
it 'receives a header other than application/x-thrift' do
|
|
44
|
-
header('Content-Type',
|
|
45
|
-
post
|
|
46
|
-
last_response.status.
|
|
43
|
+
header('Content-Type', 'application/json')
|
|
44
|
+
post '/'
|
|
45
|
+
expect(last_response.status).to be 404
|
|
47
46
|
end
|
|
48
|
-
|
|
49
47
|
end
|
|
50
48
|
|
|
51
|
-
context
|
|
52
|
-
|
|
49
|
+
context '200 response' do
|
|
53
50
|
before do
|
|
54
|
-
protocol_factory.
|
|
55
|
-
processor.
|
|
51
|
+
allow(protocol_factory).to receive(:get_protocol)
|
|
52
|
+
allow(processor).to receive(:process)
|
|
56
53
|
end
|
|
57
54
|
|
|
58
55
|
it 'creates an IOStreamTransport' do
|
|
59
|
-
header('Content-Type',
|
|
60
|
-
Thrift::IOStreamTransport.
|
|
61
|
-
post
|
|
56
|
+
header('Content-Type', 'application/x-thrift')
|
|
57
|
+
expect(Thrift::IOStreamTransport).to receive(:new).with(an_instance_of(StringIO), an_instance_of(Rack::Response))
|
|
58
|
+
post '/'
|
|
62
59
|
end
|
|
63
60
|
|
|
64
61
|
it 'fetches the right protocol based on the Transport' do
|
|
65
|
-
header('Content-Type',
|
|
66
|
-
protocol_factory.
|
|
67
|
-
post
|
|
62
|
+
header('Content-Type', 'application/x-thrift')
|
|
63
|
+
expect(protocol_factory).to receive(:get_protocol).with(an_instance_of(Thrift::IOStreamTransport))
|
|
64
|
+
post '/'
|
|
68
65
|
end
|
|
69
66
|
|
|
70
67
|
it 'status code 200' do
|
|
71
|
-
header('Content-Type',
|
|
72
|
-
post
|
|
73
|
-
last_response.ok
|
|
68
|
+
header('Content-Type', 'application/x-thrift')
|
|
69
|
+
post '/'
|
|
70
|
+
expect(last_response.ok?).to be_truthy
|
|
74
71
|
end
|
|
75
|
-
|
|
76
72
|
end
|
|
77
73
|
end
|
data/spec/serializer_spec.rb
CHANGED
|
@@ -25,19 +25,19 @@ describe 'Serializer' do
|
|
|
25
25
|
it "should serialize structs to binary by default" do
|
|
26
26
|
serializer = Thrift::Serializer.new(Thrift::BinaryProtocolAcceleratedFactory.new)
|
|
27
27
|
data = serializer.serialize(SpecNamespace::Hello.new(:greeting => "'Ello guv'nor!"))
|
|
28
|
-
data.
|
|
28
|
+
expect(data).to eq("\x0B\x00\x01\x00\x00\x00\x0E'Ello guv'nor!\x00")
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it "should serialize structs to the given protocol" do
|
|
32
|
-
protocol = Thrift::BaseProtocol.new(
|
|
33
|
-
protocol.
|
|
34
|
-
protocol.
|
|
35
|
-
protocol.
|
|
36
|
-
protocol.
|
|
37
|
-
protocol.
|
|
38
|
-
protocol.
|
|
39
|
-
protocol_factory =
|
|
40
|
-
protocol_factory.
|
|
32
|
+
protocol = Thrift::BaseProtocol.new(double("transport"))
|
|
33
|
+
expect(protocol).to receive(:write_struct_begin).with("SpecNamespace::Hello")
|
|
34
|
+
expect(protocol).to receive(:write_field_begin).with("greeting", Thrift::Types::STRING, 1)
|
|
35
|
+
expect(protocol).to receive(:write_string).with("Good day")
|
|
36
|
+
expect(protocol).to receive(:write_field_end)
|
|
37
|
+
expect(protocol).to receive(:write_field_stop)
|
|
38
|
+
expect(protocol).to receive(:write_struct_end)
|
|
39
|
+
protocol_factory = double("ProtocolFactory")
|
|
40
|
+
allow(protocol_factory).to receive(:get_protocol).and_return(protocol)
|
|
41
41
|
serializer = Thrift::Serializer.new(protocol_factory)
|
|
42
42
|
serializer.serialize(SpecNamespace::Hello.new(:greeting => "Good day"))
|
|
43
43
|
end
|
|
@@ -47,21 +47,21 @@ describe 'Serializer' do
|
|
|
47
47
|
it "should deserialize structs from binary by default" do
|
|
48
48
|
deserializer = Thrift::Deserializer.new
|
|
49
49
|
data = "\x0B\x00\x01\x00\x00\x00\x0E'Ello guv'nor!\x00"
|
|
50
|
-
deserializer.deserialize(SpecNamespace::Hello.new, data).
|
|
50
|
+
expect(deserializer.deserialize(SpecNamespace::Hello.new, data)).to eq(SpecNamespace::Hello.new(:greeting => "'Ello guv'nor!"))
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "should deserialize structs from the given protocol" do
|
|
54
|
-
protocol = Thrift::BaseProtocol.new(
|
|
55
|
-
protocol.
|
|
56
|
-
protocol.
|
|
54
|
+
protocol = Thrift::BaseProtocol.new(double("transport"))
|
|
55
|
+
expect(protocol).to receive(:read_struct_begin).and_return("SpecNamespace::Hello")
|
|
56
|
+
expect(protocol).to receive(:read_field_begin).and_return(["greeting", Thrift::Types::STRING, 1],
|
|
57
57
|
[nil, Thrift::Types::STOP, 0])
|
|
58
|
-
protocol.
|
|
59
|
-
protocol.
|
|
60
|
-
protocol.
|
|
61
|
-
protocol_factory =
|
|
62
|
-
protocol_factory.
|
|
58
|
+
expect(protocol).to receive(:read_string).and_return("Good day")
|
|
59
|
+
expect(protocol).to receive(:read_field_end)
|
|
60
|
+
expect(protocol).to receive(:read_struct_end)
|
|
61
|
+
protocol_factory = double("ProtocolFactory")
|
|
62
|
+
allow(protocol_factory).to receive(:get_protocol).and_return(protocol)
|
|
63
63
|
deserializer = Thrift::Deserializer.new(protocol_factory)
|
|
64
|
-
deserializer.deserialize(SpecNamespace::Hello.new, "").
|
|
64
|
+
expect(deserializer.deserialize(SpecNamespace::Hello.new, "")).to eq(SpecNamespace::Hello.new(:greeting => "Good day"))
|
|
65
65
|
end
|
|
66
66
|
end
|
|
67
67
|
end
|
data/spec/server_socket_spec.rb
CHANGED
|
@@ -28,52 +28,57 @@ describe 'Thrift::ServerSocket' do
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should create a handle when calling listen" do
|
|
31
|
-
TCPServer.
|
|
31
|
+
expect(TCPServer).to receive(:new).with(nil, 1234)
|
|
32
32
|
@socket.listen
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "should accept an optional host argument" do
|
|
36
36
|
@socket = Thrift::ServerSocket.new('localhost', 1234)
|
|
37
|
-
TCPServer.
|
|
37
|
+
expect(TCPServer).to receive(:new).with('localhost', 1234)
|
|
38
|
+
@socket.to_s == "server(localhost:1234)"
|
|
38
39
|
@socket.listen
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
it "should create a Thrift::Socket to wrap accepted sockets" do
|
|
42
|
-
handle =
|
|
43
|
-
TCPServer.
|
|
43
|
+
handle = double("TCPServer")
|
|
44
|
+
expect(TCPServer).to receive(:new).with(nil, 1234).and_return(handle)
|
|
44
45
|
@socket.listen
|
|
45
|
-
sock =
|
|
46
|
-
handle.
|
|
47
|
-
trans =
|
|
48
|
-
Thrift::Socket.
|
|
49
|
-
trans.
|
|
50
|
-
@socket.accept.
|
|
46
|
+
sock = double("sock")
|
|
47
|
+
expect(handle).to receive(:accept).and_return(sock)
|
|
48
|
+
trans = double("Socket")
|
|
49
|
+
expect(Thrift::Socket).to receive(:new).and_return(trans)
|
|
50
|
+
expect(trans).to receive(:handle=).with(sock)
|
|
51
|
+
expect(@socket.accept).to eq(trans)
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
it "should close the handle when closed" do
|
|
54
|
-
handle =
|
|
55
|
-
TCPServer.
|
|
55
|
+
handle = double("TCPServer", :closed? => false)
|
|
56
|
+
expect(TCPServer).to receive(:new).with(nil, 1234).and_return(handle)
|
|
56
57
|
@socket.listen
|
|
57
|
-
handle.
|
|
58
|
+
expect(handle).to receive(:close)
|
|
58
59
|
@socket.close
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
it "should return nil when accepting if there is no handle" do
|
|
62
|
-
@socket.accept.
|
|
63
|
+
expect(@socket.accept).to be_nil
|
|
63
64
|
end
|
|
64
65
|
|
|
65
66
|
it "should return true for closed? when appropriate" do
|
|
66
|
-
handle =
|
|
67
|
-
TCPServer.
|
|
67
|
+
handle = double("TCPServer", :closed? => false)
|
|
68
|
+
allow(TCPServer).to receive(:new).and_return(handle)
|
|
68
69
|
@socket.listen
|
|
69
|
-
@socket.
|
|
70
|
-
handle.
|
|
70
|
+
expect(@socket).not_to be_closed
|
|
71
|
+
allow(handle).to receive(:close)
|
|
71
72
|
@socket.close
|
|
72
|
-
@socket.
|
|
73
|
+
expect(@socket).to be_closed
|
|
73
74
|
@socket.listen
|
|
74
|
-
@socket.
|
|
75
|
-
handle.
|
|
76
|
-
@socket.
|
|
75
|
+
expect(@socket).not_to be_closed
|
|
76
|
+
allow(handle).to receive(:closed?).and_return(true)
|
|
77
|
+
expect(@socket).to be_closed
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should provide a reasonable to_s" do
|
|
81
|
+
expect(@socket.to_s).to eq("socket(:1234)")
|
|
77
82
|
end
|
|
78
83
|
end
|
|
79
84
|
end
|