slayer-thrift 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/CHANGELOG +1 -0
  2. data/InstalledFiles +1 -0
  3. data/Makefile +512 -0
  4. data/Makefile.am +49 -0
  5. data/Makefile.in +512 -0
  6. data/Manifest +103 -0
  7. data/README +43 -0
  8. data/Rakefile +102 -0
  9. data/benchmark/Benchmark.thrift +24 -0
  10. data/benchmark/benchmark.rb +271 -0
  11. data/benchmark/client.rb +74 -0
  12. data/benchmark/gen-rb/benchmark_constants.rb +10 -0
  13. data/benchmark/gen-rb/benchmark_service.rb +80 -0
  14. data/benchmark/gen-rb/benchmark_types.rb +9 -0
  15. data/benchmark/server.rb +82 -0
  16. data/benchmark/thin_server.rb +44 -0
  17. data/debug_proto_test/gen-rb/debug_proto_test_constants.rb +273 -0
  18. data/debug_proto_test/gen-rb/debug_proto_test_types.rb +705 -0
  19. data/debug_proto_test/gen-rb/empty_service.rb +24 -0
  20. data/debug_proto_test/gen-rb/inherited.rb +79 -0
  21. data/debug_proto_test/gen-rb/reverse_order_service.rb +82 -0
  22. data/debug_proto_test/gen-rb/service_for_exception_with_a_map.rb +81 -0
  23. data/debug_proto_test/gen-rb/srv.rb +330 -0
  24. data/ext/binary_protocol_accelerated.c +441 -0
  25. data/ext/binary_protocol_accelerated.h +20 -0
  26. data/ext/compact_protocol.c +618 -0
  27. data/ext/compact_protocol.h +20 -0
  28. data/ext/constants.h +96 -0
  29. data/ext/extconf.rb +30 -0
  30. data/ext/macros.h +41 -0
  31. data/ext/memory_buffer.c +131 -0
  32. data/ext/memory_buffer.h +20 -0
  33. data/ext/protocol.c +185 -0
  34. data/ext/protocol.h +20 -0
  35. data/ext/struct.c +716 -0
  36. data/ext/struct.h +25 -0
  37. data/ext/thrift_native.c +196 -0
  38. data/lib/thrift.rb +64 -0
  39. data/lib/thrift/client.rb +62 -0
  40. data/lib/thrift/core_ext.rb +23 -0
  41. data/lib/thrift/core_ext/fixnum.rb +29 -0
  42. data/lib/thrift/exceptions.rb +84 -0
  43. data/lib/thrift/processor.rb +57 -0
  44. data/lib/thrift/protocol/base_protocol.rb +290 -0
  45. data/lib/thrift/protocol/binary_protocol.rb +229 -0
  46. data/lib/thrift/protocol/binary_protocol_accelerated.rb +39 -0
  47. data/lib/thrift/protocol/compact_protocol.rb +426 -0
  48. data/lib/thrift/serializer/deserializer.rb +33 -0
  49. data/lib/thrift/serializer/serializer.rb +34 -0
  50. data/lib/thrift/server/base_server.rb +31 -0
  51. data/lib/thrift/server/mongrel_http_server.rb +58 -0
  52. data/lib/thrift/server/nonblocking_server.rb +305 -0
  53. data/lib/thrift/server/simple_server.rb +43 -0
  54. data/lib/thrift/server/thread_pool_server.rb +75 -0
  55. data/lib/thrift/server/threaded_server.rb +47 -0
  56. data/lib/thrift/struct.rb +237 -0
  57. data/lib/thrift/struct_union.rb +192 -0
  58. data/lib/thrift/thrift_native.rb +24 -0
  59. data/lib/thrift/transport/base_server_transport.rb +37 -0
  60. data/lib/thrift/transport/base_transport.rb +107 -0
  61. data/lib/thrift/transport/buffered_transport.rb +108 -0
  62. data/lib/thrift/transport/framed_transport.rb +116 -0
  63. data/lib/thrift/transport/http_client_transport.rb +51 -0
  64. data/lib/thrift/transport/io_stream_transport.rb +39 -0
  65. data/lib/thrift/transport/memory_buffer_transport.rb +125 -0
  66. data/lib/thrift/transport/server_socket.rb +63 -0
  67. data/lib/thrift/transport/socket.rb +137 -0
  68. data/lib/thrift/transport/unix_server_socket.rb +60 -0
  69. data/lib/thrift/transport/unix_socket.rb +40 -0
  70. data/lib/thrift/types.rb +101 -0
  71. data/lib/thrift/union.rb +179 -0
  72. data/script/proto_benchmark.rb +121 -0
  73. data/script/read_struct.rb +43 -0
  74. data/script/write_struct.rb +30 -0
  75. data/setup.rb +1585 -0
  76. data/slayer-thrift.gemspec +30 -0
  77. data/spec/ThriftSpec.thrift +132 -0
  78. data/spec/base_protocol_spec.rb +160 -0
  79. data/spec/base_transport_spec.rb +351 -0
  80. data/spec/binary_protocol_accelerated_spec.rb +46 -0
  81. data/spec/binary_protocol_spec.rb +61 -0
  82. data/spec/binary_protocol_spec_shared.rb +375 -0
  83. data/spec/client_spec.rb +100 -0
  84. data/spec/compact_protocol_spec.rb +133 -0
  85. data/spec/exception_spec.rb +142 -0
  86. data/spec/gen-rb/nonblocking_service.rb +272 -0
  87. data/spec/gen-rb/thrift_spec_constants.rb +10 -0
  88. data/spec/gen-rb/thrift_spec_types.rb +345 -0
  89. data/spec/http_client_spec.rb +64 -0
  90. data/spec/mongrel_http_server_spec.rb +117 -0
  91. data/spec/nonblocking_server_spec.rb +265 -0
  92. data/spec/processor_spec.rb +83 -0
  93. data/spec/serializer_spec.rb +69 -0
  94. data/spec/server_socket_spec.rb +80 -0
  95. data/spec/server_spec.rb +160 -0
  96. data/spec/socket_spec.rb +61 -0
  97. data/spec/socket_spec_shared.rb +104 -0
  98. data/spec/spec_helper.rb +58 -0
  99. data/spec/struct_spec.rb +295 -0
  100. data/spec/types_spec.rb +116 -0
  101. data/spec/union_spec.rb +193 -0
  102. data/spec/unix_socket_spec.rb +108 -0
  103. data/thrift.gemspec +30 -0
  104. data/tmp/thrift-0.7.0.gem +0 -0
  105. metadata +207 -0
@@ -0,0 +1,100 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require File.dirname(__FILE__) + '/spec_helper'
21
+
22
+ class ThriftClientSpec < Spec::ExampleGroup
23
+ include Thrift
24
+
25
+ class ClientSpec
26
+ include Thrift::Client
27
+ end
28
+
29
+ before(:each) do
30
+ @prot = mock("MockProtocol")
31
+ @client = ClientSpec.new(@prot)
32
+ end
33
+
34
+ describe Client do
35
+ it "should re-use iprot for oprot if not otherwise specified" do
36
+ @client.instance_variable_get(:'@iprot').should eql(@prot)
37
+ @client.instance_variable_get(:'@oprot').should eql(@prot)
38
+ end
39
+
40
+ it "should send a test message" do
41
+ @prot.should_receive(:write_message_begin).with('testMessage', MessageTypes::CALL, 0)
42
+ mock_args = mock('#<TestMessage_args:mock>')
43
+ mock_args.should_receive(:foo=).with('foo')
44
+ mock_args.should_receive(:bar=).with(42)
45
+ mock_args.should_receive(:write).with(@prot)
46
+ @prot.should_receive(:write_message_end)
47
+ @prot.should_receive(:trans) do
48
+ mock('trans').tee do |trans|
49
+ trans.should_receive(:flush)
50
+ end
51
+ end
52
+ klass = stub("TestMessage_args", :new => mock_args)
53
+ @client.send_message('testMessage', klass, :foo => 'foo', :bar => 42)
54
+ end
55
+
56
+ it "should increment the sequence id when sending messages" do
57
+ pending "it seems sequence ids are completely ignored right now" do
58
+ @prot.should_receive(:write_message_begin).with('testMessage', MessageTypes::CALL, 0).ordered
59
+ @prot.should_receive(:write_message_begin).with('testMessage2', MessageTypes::CALL, 1).ordered
60
+ @prot.should_receive(:write_message_begin).with('testMessage3', MessageTypes::CALL, 2).ordered
61
+ @prot.stub!(:write_message_end)
62
+ @prot.stub!(:trans).and_return mock("trans").as_null_object
63
+ @client.send_message('testMessage', mock("args class").as_null_object)
64
+ @client.send_message('testMessage2', mock("args class").as_null_object)
65
+ @client.send_message('testMessage3', mock("args class").as_null_object)
66
+ end
67
+ end
68
+
69
+ it "should receive a test message" do
70
+ @prot.should_receive(:read_message_begin).and_return [nil, MessageTypes::CALL, 0]
71
+ @prot.should_receive(:read_message_end)
72
+ mock_klass = mock("#<MockClass:mock>")
73
+ mock_klass.should_receive(:read).with(@prot)
74
+ @client.receive_message(stub("MockClass", :new => mock_klass))
75
+ end
76
+
77
+ it "should handle received exceptions" do
78
+ @prot.should_receive(:read_message_begin).and_return [nil, MessageTypes::EXCEPTION, 0]
79
+ @prot.should_receive(:read_message_end)
80
+ ApplicationException.should_receive(:new).and_return do
81
+ StandardError.new.tee do |mock_exc|
82
+ mock_exc.should_receive(:read).with(@prot)
83
+ end
84
+ end
85
+ lambda { @client.receive_message(nil) }.should raise_error(StandardError)
86
+ end
87
+
88
+ it "should close the transport if an error occurs while sending a message" do
89
+ @prot.stub!(:write_message_begin)
90
+ @prot.should_not_receive(:write_message_end)
91
+ mock_args = mock("#<TestMessage_args:mock>")
92
+ mock_args.should_receive(:write).with(@prot).and_raise(StandardError)
93
+ trans = mock("MockTransport")
94
+ @prot.stub!(:trans).and_return(trans)
95
+ trans.should_receive(:close)
96
+ klass = mock("TestMessage_args", :new => mock_args)
97
+ lambda { @client.send_message("testMessage", klass) }.should raise_error(StandardError)
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,133 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require File.dirname(__FILE__) + '/spec_helper'
21
+
22
+ describe Thrift::CompactProtocol do
23
+ TESTS = {
24
+ :byte => (-127..127).to_a,
25
+ :i16 => (0..14).map {|shift| [1 << shift, -(1 << shift)]}.flatten.sort,
26
+ :i32 => (0..30).map {|shift| [1 << shift, -(1 << shift)]}.flatten.sort,
27
+ :i64 => (0..62).map {|shift| [1 << shift, -(1 << shift)]}.flatten.sort,
28
+ :string => ["", "1", "short", "fourteen123456", "fifteen12345678", "1" * 127, "1" * 3000],
29
+ :binary => ["", "\001", "\001" * 5, "\001" * 14, "\001" * 15, "\001" * 127, "\001" * 3000],
30
+ :double => [0.0, 1.0, -1.0, 1.1, -1.1, 10000000.1, 1.0/0.0, -1.0/0.0],
31
+ :bool => [true, false]
32
+ }
33
+
34
+ it "should encode and decode naked primitives correctly" do
35
+ TESTS.each_pair do |primitive_type, test_values|
36
+ test_values.each do |value|
37
+ # puts "testing #{value}" if primitive_type == :i64
38
+ trans = Thrift::MemoryBufferTransport.new
39
+ proto = Thrift::CompactProtocol.new(trans)
40
+
41
+ proto.send(writer(primitive_type), value)
42
+ # puts "buf: #{trans.inspect_buffer}" if primitive_type == :i64
43
+ read_back = proto.send(reader(primitive_type))
44
+ read_back.should == value
45
+ end
46
+ end
47
+ end
48
+
49
+ it "should encode and decode primitives in fields correctly" do
50
+ TESTS.each_pair do |primitive_type, test_values|
51
+ final_primitive_type = primitive_type == :binary ? :string : primitive_type
52
+ thrift_type = Thrift::Types.const_get(final_primitive_type.to_s.upcase)
53
+ # puts primitive_type
54
+ test_values.each do |value|
55
+ trans = Thrift::MemoryBufferTransport.new
56
+ proto = Thrift::CompactProtocol.new(trans)
57
+
58
+ proto.write_field_begin(nil, thrift_type, 15)
59
+ proto.send(writer(primitive_type), value)
60
+ proto.write_field_end
61
+
62
+ proto = Thrift::CompactProtocol.new(trans)
63
+ name, type, id = proto.read_field_begin
64
+ type.should == thrift_type
65
+ id.should == 15
66
+ read_back = proto.send(reader(primitive_type))
67
+ read_back.should == value
68
+ proto.read_field_end
69
+ end
70
+ end
71
+ end
72
+
73
+ it "should encode and decode a monster struct correctly" do
74
+ trans = Thrift::MemoryBufferTransport.new
75
+ proto = Thrift::CompactProtocol.new(trans)
76
+
77
+ struct = CompactProtoTestStruct.new
78
+ # sets and maps don't hash well... not sure what to do here.
79
+ struct.write(proto)
80
+
81
+ struct2 = CompactProtoTestStruct.new
82
+ struct2.read(proto)
83
+ struct2.should == struct
84
+ end
85
+
86
+ it "should make method calls correctly" do
87
+ client_out_trans = Thrift::MemoryBufferTransport.new
88
+ client_out_proto = Thrift::CompactProtocol.new(client_out_trans)
89
+
90
+ client_in_trans = Thrift::MemoryBufferTransport.new
91
+ client_in_proto = Thrift::CompactProtocol.new(client_in_trans)
92
+
93
+ processor = Srv::Processor.new(JankyHandler.new)
94
+
95
+ client = Srv::Client.new(client_in_proto, client_out_proto)
96
+ client.send_Janky(1)
97
+ # puts client_out_trans.inspect_buffer
98
+ processor.process(client_out_proto, client_in_proto)
99
+ client.recv_Janky.should == 2
100
+ end
101
+
102
+ it "should deal with fields following fields that have non-delta ids" do
103
+ brcp = BreaksRubyCompactProtocol.new(
104
+ :field1 => "blah",
105
+ :field2 => BigFieldIdStruct.new(
106
+ :field1 => "string1",
107
+ :field2 => "string2"),
108
+ :field3 => 3)
109
+ ser = Thrift::Serializer.new(Thrift::CompactProtocolFactory.new)
110
+ bytes = ser.serialize(brcp)
111
+
112
+ deser = Thrift::Deserializer.new(Thrift::CompactProtocolFactory.new)
113
+ brcp2 = BreaksRubyCompactProtocol.new
114
+ deser.deserialize(brcp2, bytes)
115
+ brcp2.should == brcp
116
+ end
117
+
118
+ class JankyHandler
119
+ def Janky(i32arg)
120
+ i32arg * 2
121
+ end
122
+ end
123
+
124
+ def writer(sym)
125
+ sym = sym == :binary ? :string : sym
126
+ "write_#{sym.to_s}"
127
+ end
128
+
129
+ def reader(sym)
130
+ sym = sym == :binary ? :string : sym
131
+ "read_#{sym.to_s}"
132
+ end
133
+ end
@@ -0,0 +1,142 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require File.dirname(__FILE__) + '/spec_helper'
21
+
22
+ class ThriftExceptionSpec < Spec::ExampleGroup
23
+ include Thrift
24
+
25
+ describe Exception do
26
+ it "should have an accessible message" do
27
+ e = Exception.new("test message")
28
+ e.message.should == "test message"
29
+ end
30
+ end
31
+
32
+ describe ApplicationException do
33
+ it "should inherit from Thrift::Exception" do
34
+ ApplicationException.superclass.should == Exception
35
+ end
36
+
37
+ it "should have an accessible type and message" do
38
+ e = ApplicationException.new
39
+ e.type.should == ApplicationException::UNKNOWN
40
+ e.message.should be_nil
41
+ e = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, "test message")
42
+ e.type.should == ApplicationException::UNKNOWN_METHOD
43
+ e.message.should == "test message"
44
+ end
45
+
46
+ it "should read a struct off of a protocol" do
47
+ prot = mock("MockProtocol")
48
+ prot.should_receive(:read_struct_begin).ordered
49
+ prot.should_receive(:read_field_begin).exactly(3).times.and_return(
50
+ ["message", Types::STRING, 1],
51
+ ["type", Types::I32, 2],
52
+ [nil, Types::STOP, 0]
53
+ )
54
+ prot.should_receive(:read_string).ordered.and_return "test message"
55
+ prot.should_receive(:read_i32).ordered.and_return ApplicationException::BAD_SEQUENCE_ID
56
+ prot.should_receive(:read_field_end).exactly(2).times
57
+ prot.should_receive(:read_struct_end).ordered
58
+
59
+ e = ApplicationException.new
60
+ e.read(prot)
61
+ e.message.should == "test message"
62
+ e.type.should == ApplicationException::BAD_SEQUENCE_ID
63
+ end
64
+
65
+ it "should skip bad fields when reading a struct" do
66
+ prot = mock("MockProtocol")
67
+ prot.should_receive(:read_struct_begin).ordered
68
+ prot.should_receive(:read_field_begin).exactly(5).times.and_return(
69
+ ["type", Types::I32, 2],
70
+ ["type", Types::STRING, 2],
71
+ ["message", Types::MAP, 1],
72
+ ["message", Types::STRING, 3],
73
+ [nil, Types::STOP, 0]
74
+ )
75
+ prot.should_receive(:read_i32).and_return ApplicationException::INVALID_MESSAGE_TYPE
76
+ prot.should_receive(:skip).with(Types::STRING).twice
77
+ prot.should_receive(:skip).with(Types::MAP)
78
+ prot.should_receive(:read_field_end).exactly(4).times
79
+ prot.should_receive(:read_struct_end).ordered
80
+
81
+ e = ApplicationException.new
82
+ e.read(prot)
83
+ e.message.should be_nil
84
+ e.type.should == ApplicationException::INVALID_MESSAGE_TYPE
85
+ end
86
+
87
+ it "should write a Thrift::ApplicationException struct to the oprot" do
88
+ prot = mock("MockProtocol")
89
+ prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
90
+ prot.should_receive(:write_field_begin).with("message", Types::STRING, 1).ordered
91
+ prot.should_receive(:write_string).with("test message").ordered
92
+ prot.should_receive(:write_field_begin).with("type", Types::I32, 2).ordered
93
+ prot.should_receive(:write_i32).with(ApplicationException::UNKNOWN_METHOD).ordered
94
+ prot.should_receive(:write_field_end).twice
95
+ prot.should_receive(:write_field_stop).ordered
96
+ prot.should_receive(:write_struct_end).ordered
97
+
98
+ e = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, "test message")
99
+ e.write(prot)
100
+ end
101
+
102
+ it "should skip nil fields when writing to the oprot" do
103
+ prot = mock("MockProtocol")
104
+ prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
105
+ prot.should_receive(:write_field_begin).with("message", Types::STRING, 1).ordered
106
+ prot.should_receive(:write_string).with("test message").ordered
107
+ prot.should_receive(:write_field_end).ordered
108
+ prot.should_receive(:write_field_stop).ordered
109
+ prot.should_receive(:write_struct_end).ordered
110
+
111
+ e = ApplicationException.new(nil, "test message")
112
+ e.write(prot)
113
+
114
+ prot = mock("MockProtocol")
115
+ prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
116
+ prot.should_receive(:write_field_begin).with("type", Types::I32, 2).ordered
117
+ prot.should_receive(:write_i32).with(ApplicationException::BAD_SEQUENCE_ID).ordered
118
+ prot.should_receive(:write_field_end).ordered
119
+ prot.should_receive(:write_field_stop).ordered
120
+ prot.should_receive(:write_struct_end).ordered
121
+
122
+ e = ApplicationException.new(ApplicationException::BAD_SEQUENCE_ID)
123
+ e.write(prot)
124
+
125
+ prot = mock("MockProtocol")
126
+ prot.should_receive(:write_struct_begin).with("Thrift::ApplicationException").ordered
127
+ prot.should_receive(:write_field_stop).ordered
128
+ prot.should_receive(:write_struct_end).ordered
129
+
130
+ e = ApplicationException.new(nil)
131
+ e.write(prot)
132
+ end
133
+ end
134
+
135
+ describe ProtocolException do
136
+ it "should have an accessible type" do
137
+ prot = ProtocolException.new(ProtocolException::SIZE_LIMIT, "message")
138
+ prot.type.should == ProtocolException::SIZE_LIMIT
139
+ prot.message.should == "message"
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,272 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.7.0)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'thrift_spec_types'
9
+
10
+ module SpecNamespace
11
+ module NonblockingService
12
+ class Client
13
+ include ::Thrift::Client
14
+
15
+ def greeting(english)
16
+ send_greeting(english)
17
+ return recv_greeting()
18
+ end
19
+
20
+ def send_greeting(english)
21
+ send_message('greeting', Greeting_args, :english => english)
22
+ end
23
+
24
+ def recv_greeting()
25
+ result = receive_message(Greeting_result)
26
+ return result.success unless result.success.nil?
27
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'greeting failed: unknown result')
28
+ end
29
+
30
+ def block()
31
+ send_block()
32
+ return recv_block()
33
+ end
34
+
35
+ def send_block()
36
+ send_message('block', Block_args)
37
+ end
38
+
39
+ def recv_block()
40
+ result = receive_message(Block_result)
41
+ return result.success unless result.success.nil?
42
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'block failed: unknown result')
43
+ end
44
+
45
+ def unblock(n)
46
+ send_unblock(n)
47
+ end
48
+
49
+ def send_unblock(n)
50
+ send_message('unblock', Unblock_args, :n => n)
51
+ end
52
+ def shutdown()
53
+ send_shutdown()
54
+ end
55
+
56
+ def send_shutdown()
57
+ send_message('shutdown', Shutdown_args)
58
+ end
59
+ def sleep(seconds)
60
+ send_sleep(seconds)
61
+ recv_sleep()
62
+ end
63
+
64
+ def send_sleep(seconds)
65
+ send_message('sleep', Sleep_args, :seconds => seconds)
66
+ end
67
+
68
+ def recv_sleep()
69
+ result = receive_message(Sleep_result)
70
+ return
71
+ end
72
+
73
+ end
74
+
75
+ class Processor
76
+ include ::Thrift::Processor
77
+
78
+ def process_greeting(seqid, iprot, oprot)
79
+ args = read_args(iprot, Greeting_args)
80
+ result = Greeting_result.new()
81
+ result.success = @handler.greeting(args.english)
82
+ write_result(result, oprot, 'greeting', seqid)
83
+ end
84
+
85
+ def process_block(seqid, iprot, oprot)
86
+ args = read_args(iprot, Block_args)
87
+ result = Block_result.new()
88
+ result.success = @handler.block()
89
+ write_result(result, oprot, 'block', seqid)
90
+ end
91
+
92
+ def process_unblock(seqid, iprot, oprot)
93
+ args = read_args(iprot, Unblock_args)
94
+ @handler.unblock(args.n)
95
+ return
96
+ end
97
+
98
+ def process_shutdown(seqid, iprot, oprot)
99
+ args = read_args(iprot, Shutdown_args)
100
+ @handler.shutdown()
101
+ return
102
+ end
103
+
104
+ def process_sleep(seqid, iprot, oprot)
105
+ args = read_args(iprot, Sleep_args)
106
+ result = Sleep_result.new()
107
+ @handler.sleep(args.seconds)
108
+ write_result(result, oprot, 'sleep', seqid)
109
+ end
110
+
111
+ end
112
+
113
+ # HELPER FUNCTIONS AND STRUCTURES
114
+
115
+ class Greeting_args
116
+ include ::Thrift::Struct, ::Thrift::Struct_Union
117
+ ENGLISH = 1
118
+
119
+ FIELDS = {
120
+ ENGLISH => {:type => ::Thrift::Types::BOOL, :name => 'english'}
121
+ }
122
+
123
+ def struct_fields; FIELDS; end
124
+
125
+ def validate
126
+ end
127
+
128
+ ::Thrift::Struct.generate_accessors self
129
+ end
130
+
131
+ class Greeting_result
132
+ include ::Thrift::Struct, ::Thrift::Struct_Union
133
+ SUCCESS = 0
134
+
135
+ FIELDS = {
136
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => SpecNamespace::Hello}
137
+ }
138
+
139
+ def struct_fields; FIELDS; end
140
+
141
+ def validate
142
+ end
143
+
144
+ ::Thrift::Struct.generate_accessors self
145
+ end
146
+
147
+ class Block_args
148
+ include ::Thrift::Struct, ::Thrift::Struct_Union
149
+
150
+ FIELDS = {
151
+
152
+ }
153
+
154
+ def struct_fields; FIELDS; end
155
+
156
+ def validate
157
+ end
158
+
159
+ ::Thrift::Struct.generate_accessors self
160
+ end
161
+
162
+ class Block_result
163
+ include ::Thrift::Struct, ::Thrift::Struct_Union
164
+ SUCCESS = 0
165
+
166
+ FIELDS = {
167
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
168
+ }
169
+
170
+ def struct_fields; FIELDS; end
171
+
172
+ def validate
173
+ end
174
+
175
+ ::Thrift::Struct.generate_accessors self
176
+ end
177
+
178
+ class Unblock_args
179
+ include ::Thrift::Struct, ::Thrift::Struct_Union
180
+ N = 1
181
+
182
+ FIELDS = {
183
+ N => {:type => ::Thrift::Types::I32, :name => 'n'}
184
+ }
185
+
186
+ def struct_fields; FIELDS; end
187
+
188
+ def validate
189
+ end
190
+
191
+ ::Thrift::Struct.generate_accessors self
192
+ end
193
+
194
+ class Unblock_result
195
+ include ::Thrift::Struct, ::Thrift::Struct_Union
196
+
197
+ FIELDS = {
198
+
199
+ }
200
+
201
+ def struct_fields; FIELDS; end
202
+
203
+ def validate
204
+ end
205
+
206
+ ::Thrift::Struct.generate_accessors self
207
+ end
208
+
209
+ class Shutdown_args
210
+ include ::Thrift::Struct, ::Thrift::Struct_Union
211
+
212
+ FIELDS = {
213
+
214
+ }
215
+
216
+ def struct_fields; FIELDS; end
217
+
218
+ def validate
219
+ end
220
+
221
+ ::Thrift::Struct.generate_accessors self
222
+ end
223
+
224
+ class Shutdown_result
225
+ include ::Thrift::Struct, ::Thrift::Struct_Union
226
+
227
+ FIELDS = {
228
+
229
+ }
230
+
231
+ def struct_fields; FIELDS; end
232
+
233
+ def validate
234
+ end
235
+
236
+ ::Thrift::Struct.generate_accessors self
237
+ end
238
+
239
+ class Sleep_args
240
+ include ::Thrift::Struct, ::Thrift::Struct_Union
241
+ SECONDS = 1
242
+
243
+ FIELDS = {
244
+ SECONDS => {:type => ::Thrift::Types::DOUBLE, :name => 'seconds'}
245
+ }
246
+
247
+ def struct_fields; FIELDS; end
248
+
249
+ def validate
250
+ end
251
+
252
+ ::Thrift::Struct.generate_accessors self
253
+ end
254
+
255
+ class Sleep_result
256
+ include ::Thrift::Struct, ::Thrift::Struct_Union
257
+
258
+ FIELDS = {
259
+
260
+ }
261
+
262
+ def struct_fields; FIELDS; end
263
+
264
+ def validate
265
+ end
266
+
267
+ ::Thrift::Struct.generate_accessors self
268
+ end
269
+
270
+ end
271
+
272
+ end