thrift 0.8.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/{README → README.md} +0 -0
  3. data/ext/binary_protocol_accelerated.c +33 -14
  4. data/ext/bytes.c +36 -0
  5. data/ext/bytes.h +31 -0
  6. data/ext/compact_protocol.c +27 -8
  7. data/ext/constants.h +8 -5
  8. data/ext/extconf.rb +5 -1
  9. data/ext/memory_buffer.c +12 -9
  10. data/ext/protocol.c +0 -185
  11. data/ext/protocol.h +0 -20
  12. data/ext/strlcpy.h +7 -3
  13. data/ext/struct.c +27 -7
  14. data/ext/thrift_native.c +16 -11
  15. data/lib/thrift.rb +10 -4
  16. data/lib/thrift/bytes.rb +131 -0
  17. data/lib/thrift/client.rb +13 -4
  18. data/lib/thrift/exceptions.rb +3 -0
  19. data/lib/thrift/multiplexed_processor.rb +76 -0
  20. data/lib/thrift/processor.rb +24 -6
  21. data/lib/thrift/protocol/base_protocol.rb +109 -12
  22. data/lib/thrift/protocol/binary_protocol.rb +22 -7
  23. data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
  24. data/lib/thrift/protocol/compact_protocol.rb +23 -6
  25. data/lib/thrift/protocol/json_protocol.rb +786 -0
  26. data/lib/thrift/protocol/multiplexed_protocol.rb +44 -0
  27. data/lib/thrift/protocol/protocol_decorator.rb +194 -0
  28. data/lib/thrift/server/base_server.rb +8 -2
  29. data/lib/thrift/server/mongrel_http_server.rb +2 -0
  30. data/lib/thrift/server/simple_server.rb +5 -1
  31. data/lib/thrift/server/thin_http_server.rb +91 -0
  32. data/lib/thrift/server/thread_pool_server.rb +5 -1
  33. data/lib/thrift/server/threaded_server.rb +5 -1
  34. data/lib/thrift/struct.rb +1 -1
  35. data/lib/thrift/struct_union.rb +2 -2
  36. data/lib/thrift/transport/base_server_transport.rb +1 -1
  37. data/lib/thrift/transport/base_transport.rb +30 -20
  38. data/lib/thrift/transport/buffered_transport.rb +25 -11
  39. data/lib/thrift/transport/framed_transport.rb +20 -11
  40. data/lib/thrift/transport/http_client_transport.rb +16 -6
  41. data/lib/thrift/transport/io_stream_transport.rb +5 -2
  42. data/lib/thrift/transport/memory_buffer_transport.rb +10 -6
  43. data/lib/thrift/transport/server_socket.rb +6 -1
  44. data/lib/thrift/transport/socket.rb +23 -17
  45. data/lib/thrift/transport/ssl_server_socket.rb +41 -0
  46. data/lib/thrift/transport/ssl_socket.rb +51 -0
  47. data/lib/thrift/transport/unix_server_socket.rb +5 -1
  48. data/lib/thrift/transport/unix_socket.rb +5 -1
  49. data/lib/thrift/union.rb +3 -6
  50. data/spec/BaseService.thrift +27 -0
  51. data/spec/ExtendedService.thrift +25 -0
  52. data/spec/Referenced.thrift +44 -0
  53. data/spec/ThriftNamespacedSpec.thrift +53 -0
  54. data/spec/ThriftSpec.thrift +52 -1
  55. data/spec/base_protocol_spec.rb +158 -93
  56. data/spec/base_transport_spec.rb +194 -157
  57. data/spec/binary_protocol_accelerated_spec.rb +14 -14
  58. data/spec/binary_protocol_spec.rb +29 -16
  59. data/spec/binary_protocol_spec_shared.rb +148 -65
  60. data/spec/bytes_spec.rb +160 -0
  61. data/spec/client_spec.rb +45 -47
  62. data/spec/compact_protocol_spec.rb +36 -22
  63. data/spec/exception_spec.rb +79 -80
  64. data/spec/flat_spec.rb +62 -0
  65. data/spec/http_client_spec.rb +91 -16
  66. data/spec/json_protocol_spec.rb +552 -0
  67. data/spec/namespaced_spec.rb +67 -0
  68. data/spec/nonblocking_server_spec.rb +26 -28
  69. data/spec/processor_spec.rb +29 -32
  70. data/spec/serializer_spec.rb +31 -33
  71. data/spec/server_socket_spec.rb +32 -28
  72. data/spec/server_spec.rb +112 -84
  73. data/spec/socket_spec.rb +27 -20
  74. data/spec/socket_spec_shared.rb +32 -32
  75. data/spec/spec_helper.rb +17 -11
  76. data/spec/ssl_server_socket_spec.rb +34 -0
  77. data/spec/ssl_socket_spec.rb +78 -0
  78. data/spec/struct_nested_containers_spec.rb +191 -0
  79. data/spec/struct_spec.rb +159 -161
  80. data/spec/thin_http_server_spec.rb +141 -0
  81. data/spec/types_spec.rb +71 -69
  82. data/spec/union_spec.rb +97 -76
  83. data/spec/unix_socket_spec.rb +49 -41
  84. metadata +268 -188
  85. data/CHANGELOG +0 -1
  86. data/benchmark/gen-rb/benchmark_constants.rb +0 -10
  87. data/benchmark/gen-rb/benchmark_service.rb +0 -80
  88. data/benchmark/gen-rb/benchmark_types.rb +0 -9
  89. data/spec/gen-rb/nonblocking_service.rb +0 -272
  90. data/spec/gen-rb/thrift_spec_constants.rb +0 -10
  91. data/spec/gen-rb/thrift_spec_types.rb +0 -345
  92. data/spec/mongrel_http_server_spec.rb +0 -117
  93. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +0 -273
  94. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +0 -760
  95. data/test/debug_proto/gen-rb/empty_service.rb +0 -24
  96. data/test/debug_proto/gen-rb/inherited.rb +0 -79
  97. data/test/debug_proto/gen-rb/reverse_order_service.rb +0 -82
  98. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +0 -81
  99. data/test/debug_proto/gen-rb/srv.rb +0 -330
@@ -1,24 +0,0 @@
1
- #
2
- # Autogenerated by Thrift Compiler (0.8.0)
3
- #
4
- # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- #
6
-
7
- require 'thrift'
8
- require 'debug_proto_test_types'
9
-
10
- module EmptyService
11
- class Client
12
- include ::Thrift::Client
13
-
14
- end
15
-
16
- class Processor
17
- include ::Thrift::Processor
18
-
19
- end
20
-
21
- # HELPER FUNCTIONS AND STRUCTURES
22
-
23
- end
24
-
@@ -1,79 +0,0 @@
1
- #
2
- # Autogenerated by Thrift Compiler (0.8.0)
3
- #
4
- # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- #
6
-
7
- require 'thrift'
8
- require 'srv'
9
- require 'debug_proto_test_types'
10
-
11
- module Inherited
12
- class Client < Srv::Client
13
- include ::Thrift::Client
14
-
15
- def identity(arg)
16
- send_identity(arg)
17
- return recv_identity()
18
- end
19
-
20
- def send_identity(arg)
21
- send_message('identity', Identity_args, :arg => arg)
22
- end
23
-
24
- def recv_identity()
25
- result = receive_message(Identity_result)
26
- return result.success unless result.success.nil?
27
- raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'identity failed: unknown result')
28
- end
29
-
30
- end
31
-
32
- class Processor < Srv::Processor
33
- include ::Thrift::Processor
34
-
35
- def process_identity(seqid, iprot, oprot)
36
- args = read_args(iprot, Identity_args)
37
- result = Identity_result.new()
38
- result.success = @handler.identity(args.arg)
39
- write_result(result, oprot, 'identity', seqid)
40
- end
41
-
42
- end
43
-
44
- # HELPER FUNCTIONS AND STRUCTURES
45
-
46
- class Identity_args
47
- include ::Thrift::Struct, ::Thrift::Struct_Union
48
- ARG = 1
49
-
50
- FIELDS = {
51
- ARG => {:type => ::Thrift::Types::I32, :name => 'arg'}
52
- }
53
-
54
- def struct_fields; FIELDS; end
55
-
56
- def validate
57
- end
58
-
59
- ::Thrift::Struct.generate_accessors self
60
- end
61
-
62
- class Identity_result
63
- include ::Thrift::Struct, ::Thrift::Struct_Union
64
- SUCCESS = 0
65
-
66
- FIELDS = {
67
- SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
68
- }
69
-
70
- def struct_fields; FIELDS; end
71
-
72
- def validate
73
- end
74
-
75
- ::Thrift::Struct.generate_accessors self
76
- end
77
-
78
- end
79
-
@@ -1,82 +0,0 @@
1
- #
2
- # Autogenerated by Thrift Compiler (0.8.0)
3
- #
4
- # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- #
6
-
7
- require 'thrift'
8
- require 'debug_proto_test_types'
9
-
10
- module ReverseOrderService
11
- class Client
12
- include ::Thrift::Client
13
-
14
- def myMethod(first, second, third, fourth)
15
- send_myMethod(first, second, third, fourth)
16
- recv_myMethod()
17
- end
18
-
19
- def send_myMethod(first, second, third, fourth)
20
- send_message('myMethod', MyMethod_args, :first => first, :second => second, :third => third, :fourth => fourth)
21
- end
22
-
23
- def recv_myMethod()
24
- result = receive_message(MyMethod_result)
25
- return
26
- end
27
-
28
- end
29
-
30
- class Processor
31
- include ::Thrift::Processor
32
-
33
- def process_myMethod(seqid, iprot, oprot)
34
- args = read_args(iprot, MyMethod_args)
35
- result = MyMethod_result.new()
36
- @handler.myMethod(args.first, args.second, args.third, args.fourth)
37
- write_result(result, oprot, 'myMethod', seqid)
38
- end
39
-
40
- end
41
-
42
- # HELPER FUNCTIONS AND STRUCTURES
43
-
44
- class MyMethod_args
45
- include ::Thrift::Struct, ::Thrift::Struct_Union
46
- FIRST = 4
47
- SECOND = 3
48
- THIRD = 2
49
- FOURTH = 1
50
-
51
- FIELDS = {
52
- FIRST => {:type => ::Thrift::Types::STRING, :name => 'first'},
53
- SECOND => {:type => ::Thrift::Types::I16, :name => 'second'},
54
- THIRD => {:type => ::Thrift::Types::I32, :name => 'third'},
55
- FOURTH => {:type => ::Thrift::Types::I64, :name => 'fourth'}
56
- }
57
-
58
- def struct_fields; FIELDS; end
59
-
60
- def validate
61
- end
62
-
63
- ::Thrift::Struct.generate_accessors self
64
- end
65
-
66
- class MyMethod_result
67
- include ::Thrift::Struct, ::Thrift::Struct_Union
68
-
69
- FIELDS = {
70
-
71
- }
72
-
73
- def struct_fields; FIELDS; end
74
-
75
- def validate
76
- end
77
-
78
- ::Thrift::Struct.generate_accessors self
79
- end
80
-
81
- end
82
-
@@ -1,81 +0,0 @@
1
- #
2
- # Autogenerated by Thrift Compiler (0.8.0)
3
- #
4
- # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- #
6
-
7
- require 'thrift'
8
- require 'debug_proto_test_types'
9
-
10
- module ServiceForExceptionWithAMap
11
- class Client
12
- include ::Thrift::Client
13
-
14
- def methodThatThrowsAnException()
15
- send_methodThatThrowsAnException()
16
- recv_methodThatThrowsAnException()
17
- end
18
-
19
- def send_methodThatThrowsAnException()
20
- send_message('methodThatThrowsAnException', MethodThatThrowsAnException_args)
21
- end
22
-
23
- def recv_methodThatThrowsAnException()
24
- result = receive_message(MethodThatThrowsAnException_result)
25
- raise result.xwamap unless result.xwamap.nil?
26
- return
27
- end
28
-
29
- end
30
-
31
- class Processor
32
- include ::Thrift::Processor
33
-
34
- def process_methodThatThrowsAnException(seqid, iprot, oprot)
35
- args = read_args(iprot, MethodThatThrowsAnException_args)
36
- result = MethodThatThrowsAnException_result.new()
37
- begin
38
- @handler.methodThatThrowsAnException()
39
- rescue ExceptionWithAMap => xwamap
40
- result.xwamap = xwamap
41
- end
42
- write_result(result, oprot, 'methodThatThrowsAnException', seqid)
43
- end
44
-
45
- end
46
-
47
- # HELPER FUNCTIONS AND STRUCTURES
48
-
49
- class MethodThatThrowsAnException_args
50
- include ::Thrift::Struct, ::Thrift::Struct_Union
51
-
52
- FIELDS = {
53
-
54
- }
55
-
56
- def struct_fields; FIELDS; end
57
-
58
- def validate
59
- end
60
-
61
- ::Thrift::Struct.generate_accessors self
62
- end
63
-
64
- class MethodThatThrowsAnException_result
65
- include ::Thrift::Struct, ::Thrift::Struct_Union
66
- XWAMAP = 1
67
-
68
- FIELDS = {
69
- XWAMAP => {:type => ::Thrift::Types::STRUCT, :name => 'xwamap', :class => ExceptionWithAMap}
70
- }
71
-
72
- def struct_fields; FIELDS; end
73
-
74
- def validate
75
- end
76
-
77
- ::Thrift::Struct.generate_accessors self
78
- end
79
-
80
- end
81
-
@@ -1,330 +0,0 @@
1
- #
2
- # Autogenerated by Thrift Compiler (0.8.0)
3
- #
4
- # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
- #
6
-
7
- require 'thrift'
8
- require 'debug_proto_test_types'
9
-
10
- module Srv
11
- class Client
12
- include ::Thrift::Client
13
-
14
- def Janky(arg)
15
- send_Janky(arg)
16
- return recv_Janky()
17
- end
18
-
19
- def send_Janky(arg)
20
- send_message('Janky', Janky_args, :arg => arg)
21
- end
22
-
23
- def recv_Janky()
24
- result = receive_message(Janky_result)
25
- return result.success unless result.success.nil?
26
- raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'Janky failed: unknown result')
27
- end
28
-
29
- def voidMethod()
30
- send_voidMethod()
31
- recv_voidMethod()
32
- end
33
-
34
- def send_voidMethod()
35
- send_message('voidMethod', VoidMethod_args)
36
- end
37
-
38
- def recv_voidMethod()
39
- result = receive_message(VoidMethod_result)
40
- return
41
- end
42
-
43
- def primitiveMethod()
44
- send_primitiveMethod()
45
- return recv_primitiveMethod()
46
- end
47
-
48
- def send_primitiveMethod()
49
- send_message('primitiveMethod', PrimitiveMethod_args)
50
- end
51
-
52
- def recv_primitiveMethod()
53
- result = receive_message(PrimitiveMethod_result)
54
- return result.success unless result.success.nil?
55
- raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'primitiveMethod failed: unknown result')
56
- end
57
-
58
- def structMethod()
59
- send_structMethod()
60
- return recv_structMethod()
61
- end
62
-
63
- def send_structMethod()
64
- send_message('structMethod', StructMethod_args)
65
- end
66
-
67
- def recv_structMethod()
68
- result = receive_message(StructMethod_result)
69
- return result.success unless result.success.nil?
70
- raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'structMethod failed: unknown result')
71
- end
72
-
73
- def methodWithDefaultArgs(something)
74
- send_methodWithDefaultArgs(something)
75
- recv_methodWithDefaultArgs()
76
- end
77
-
78
- def send_methodWithDefaultArgs(something)
79
- send_message('methodWithDefaultArgs', MethodWithDefaultArgs_args, :something => something)
80
- end
81
-
82
- def recv_methodWithDefaultArgs()
83
- result = receive_message(MethodWithDefaultArgs_result)
84
- return
85
- end
86
-
87
- def onewayMethod()
88
- send_onewayMethod()
89
- end
90
-
91
- def send_onewayMethod()
92
- send_message('onewayMethod', OnewayMethod_args)
93
- end
94
- end
95
-
96
- class Processor
97
- include ::Thrift::Processor
98
-
99
- def process_Janky(seqid, iprot, oprot)
100
- args = read_args(iprot, Janky_args)
101
- result = Janky_result.new()
102
- result.success = @handler.Janky(args.arg)
103
- write_result(result, oprot, 'Janky', seqid)
104
- end
105
-
106
- def process_voidMethod(seqid, iprot, oprot)
107
- args = read_args(iprot, VoidMethod_args)
108
- result = VoidMethod_result.new()
109
- @handler.voidMethod()
110
- write_result(result, oprot, 'voidMethod', seqid)
111
- end
112
-
113
- def process_primitiveMethod(seqid, iprot, oprot)
114
- args = read_args(iprot, PrimitiveMethod_args)
115
- result = PrimitiveMethod_result.new()
116
- result.success = @handler.primitiveMethod()
117
- write_result(result, oprot, 'primitiveMethod', seqid)
118
- end
119
-
120
- def process_structMethod(seqid, iprot, oprot)
121
- args = read_args(iprot, StructMethod_args)
122
- result = StructMethod_result.new()
123
- result.success = @handler.structMethod()
124
- write_result(result, oprot, 'structMethod', seqid)
125
- end
126
-
127
- def process_methodWithDefaultArgs(seqid, iprot, oprot)
128
- args = read_args(iprot, MethodWithDefaultArgs_args)
129
- result = MethodWithDefaultArgs_result.new()
130
- @handler.methodWithDefaultArgs(args.something)
131
- write_result(result, oprot, 'methodWithDefaultArgs', seqid)
132
- end
133
-
134
- def process_onewayMethod(seqid, iprot, oprot)
135
- args = read_args(iprot, OnewayMethod_args)
136
- @handler.onewayMethod()
137
- return
138
- end
139
-
140
- end
141
-
142
- # HELPER FUNCTIONS AND STRUCTURES
143
-
144
- class Janky_args
145
- include ::Thrift::Struct, ::Thrift::Struct_Union
146
- ARG = 1
147
-
148
- FIELDS = {
149
- ARG => {:type => ::Thrift::Types::I32, :name => 'arg'}
150
- }
151
-
152
- def struct_fields; FIELDS; end
153
-
154
- def validate
155
- end
156
-
157
- ::Thrift::Struct.generate_accessors self
158
- end
159
-
160
- class Janky_result
161
- include ::Thrift::Struct, ::Thrift::Struct_Union
162
- SUCCESS = 0
163
-
164
- FIELDS = {
165
- SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
166
- }
167
-
168
- def struct_fields; FIELDS; end
169
-
170
- def validate
171
- end
172
-
173
- ::Thrift::Struct.generate_accessors self
174
- end
175
-
176
- class VoidMethod_args
177
- include ::Thrift::Struct, ::Thrift::Struct_Union
178
-
179
- FIELDS = {
180
-
181
- }
182
-
183
- def struct_fields; FIELDS; end
184
-
185
- def validate
186
- end
187
-
188
- ::Thrift::Struct.generate_accessors self
189
- end
190
-
191
- class VoidMethod_result
192
- include ::Thrift::Struct, ::Thrift::Struct_Union
193
-
194
- FIELDS = {
195
-
196
- }
197
-
198
- def struct_fields; FIELDS; end
199
-
200
- def validate
201
- end
202
-
203
- ::Thrift::Struct.generate_accessors self
204
- end
205
-
206
- class PrimitiveMethod_args
207
- include ::Thrift::Struct, ::Thrift::Struct_Union
208
-
209
- FIELDS = {
210
-
211
- }
212
-
213
- def struct_fields; FIELDS; end
214
-
215
- def validate
216
- end
217
-
218
- ::Thrift::Struct.generate_accessors self
219
- end
220
-
221
- class PrimitiveMethod_result
222
- include ::Thrift::Struct, ::Thrift::Struct_Union
223
- SUCCESS = 0
224
-
225
- FIELDS = {
226
- SUCCESS => {:type => ::Thrift::Types::I32, :name => 'success'}
227
- }
228
-
229
- def struct_fields; FIELDS; end
230
-
231
- def validate
232
- end
233
-
234
- ::Thrift::Struct.generate_accessors self
235
- end
236
-
237
- class StructMethod_args
238
- include ::Thrift::Struct, ::Thrift::Struct_Union
239
-
240
- FIELDS = {
241
-
242
- }
243
-
244
- def struct_fields; FIELDS; end
245
-
246
- def validate
247
- end
248
-
249
- ::Thrift::Struct.generate_accessors self
250
- end
251
-
252
- class StructMethod_result
253
- include ::Thrift::Struct, ::Thrift::Struct_Union
254
- SUCCESS = 0
255
-
256
- FIELDS = {
257
- SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => CompactProtoTestStruct}
258
- }
259
-
260
- def struct_fields; FIELDS; end
261
-
262
- def validate
263
- end
264
-
265
- ::Thrift::Struct.generate_accessors self
266
- end
267
-
268
- class MethodWithDefaultArgs_args
269
- include ::Thrift::Struct, ::Thrift::Struct_Union
270
- SOMETHING = 1
271
-
272
- FIELDS = {
273
- SOMETHING => {:type => ::Thrift::Types::I32, :name => 'something', :default => 2}
274
- }
275
-
276
- def struct_fields; FIELDS; end
277
-
278
- def validate
279
- end
280
-
281
- ::Thrift::Struct.generate_accessors self
282
- end
283
-
284
- class MethodWithDefaultArgs_result
285
- include ::Thrift::Struct, ::Thrift::Struct_Union
286
-
287
- FIELDS = {
288
-
289
- }
290
-
291
- def struct_fields; FIELDS; end
292
-
293
- def validate
294
- end
295
-
296
- ::Thrift::Struct.generate_accessors self
297
- end
298
-
299
- class OnewayMethod_args
300
- include ::Thrift::Struct, ::Thrift::Struct_Union
301
-
302
- FIELDS = {
303
-
304
- }
305
-
306
- def struct_fields; FIELDS; end
307
-
308
- def validate
309
- end
310
-
311
- ::Thrift::Struct.generate_accessors self
312
- end
313
-
314
- class OnewayMethod_result
315
- include ::Thrift::Struct, ::Thrift::Struct_Union
316
-
317
- FIELDS = {
318
-
319
- }
320
-
321
- def struct_fields; FIELDS; end
322
-
323
- def validate
324
- end
325
-
326
- ::Thrift::Struct.generate_accessors self
327
- end
328
-
329
- end
330
-