thrift-client 0.1.0 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/thrift_client.rb +6 -5
  3. data/lib/thrift_client/abstract_thrift_client.rb +106 -69
  4. data/lib/thrift_client/pool.rb +34 -0
  5. data/lib/thrift_client/pool/fiber_connection_pool.rb +67 -0
  6. data/lib/thrift_client/pool/thread_connection_pool.rb +69 -0
  7. data/lib/thrift_client/{abstract_server.rb → server.rb} +62 -60
  8. data/lib/thrift_client/thrift/client.rb +15 -0
  9. data/lib/thrift_client/thrift/processor.rb +44 -0
  10. data/lib/thrift_client/{thrift.rb → thrift/protocol.rb} +1 -72
  11. data/lib/thrift_client/thrift/struct.rb +15 -0
  12. data/lib/thrift_client/thrift/transport.rb +208 -0
  13. data/test/em_test.rb +1 -0
  14. data/test/foobar/bar_service.rb +133 -0
  15. data/test/foobar/common_service.rb +388 -0
  16. data/test/foobar/foo_service.rb +133 -0
  17. data/test/{foobar_constants.rb → foobar/foobar_constants.rb} +3 -3
  18. data/test/{foobar_types.rb → foobar/foobar_types.rb} +12 -10
  19. data/test/foobar/handler.rb +74 -0
  20. data/test/helper.rb +50 -0
  21. data/test/passport.rb +51 -0
  22. data/test/start_server.rb +8 -0
  23. data/test/test.rb +27 -0
  24. data/test/test_client.rb +111 -0
  25. data/test/test_config.rb +54 -0
  26. data/test/test_connection_pool.rb +43 -0
  27. data/test/test_eventmachine_transprot.rb +146 -0
  28. data/test/test_multiplexed.rb +62 -0
  29. metadata +47 -24
  30. data/lib/thrift_client/multi_client_server.rb +0 -59
  31. data/lib/thrift_client/single_client_server.rb +0 -37
  32. data/test/client_test.rb +0 -172
  33. data/test/foobar_service.rb +0 -282
  34. data/test/multiplexed_protocol_test.rb +0 -60
  35. data/test/multiplexed_server.rb +0 -102
  36. data/test/server.rb +0 -97
@@ -0,0 +1 @@
1
+ require 'eventmachine'
@@ -0,0 +1,133 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'foobar/foobar_types'
9
+
10
+ module Test
11
+ module BarService
12
+ class Client
13
+ include ::Thrift::Client
14
+
15
+ def getBar()
16
+ send_getBar()
17
+ return recv_getBar()
18
+ end
19
+
20
+ def send_getBar()
21
+ send_message('getBar', GetBar_args)
22
+ end
23
+
24
+ def recv_getBar()
25
+ result = receive_message(GetBar_result)
26
+ return result.success unless result.success.nil?
27
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'getBar failed: unknown result')
28
+ end
29
+
30
+ def putBar(bar)
31
+ send_putBar(bar)
32
+ return recv_putBar()
33
+ end
34
+
35
+ def send_putBar(bar)
36
+ send_message('putBar', PutBar_args, :bar => bar)
37
+ end
38
+
39
+ def recv_putBar()
40
+ result = receive_message(PutBar_result)
41
+ return result.success unless result.success.nil?
42
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'putBar failed: unknown result')
43
+ end
44
+
45
+ end
46
+
47
+ class Processor
48
+ include ::Thrift::Processor
49
+
50
+ def process_getBar(seqid, iprot, oprot)
51
+ args = read_args(iprot, GetBar_args)
52
+ result = GetBar_result.new()
53
+ result.success = @handler.getBar()
54
+ write_result(result, oprot, 'getBar', seqid)
55
+ end
56
+
57
+ def process_putBar(seqid, iprot, oprot)
58
+ args = read_args(iprot, PutBar_args)
59
+ result = PutBar_result.new()
60
+ result.success = @handler.putBar(args.bar)
61
+ write_result(result, oprot, 'putBar', seqid)
62
+ end
63
+
64
+ end
65
+
66
+ # HELPER FUNCTIONS AND STRUCTURES
67
+
68
+ class GetBar_args
69
+ include ::Thrift::Struct, ::Thrift::Struct_Union
70
+
71
+ FIELDS = {
72
+
73
+ }
74
+
75
+ def struct_fields; FIELDS; end
76
+
77
+ def validate
78
+ end
79
+
80
+ ::Thrift::Struct.generate_accessors self
81
+ end
82
+
83
+ class GetBar_result
84
+ include ::Thrift::Struct, ::Thrift::Struct_Union
85
+ SUCCESS = 0
86
+
87
+ FIELDS = {
88
+ SUCCESS => {:type => ::Thrift::Types::STRUCT, :name => 'success', :class => ::Test::Bar}
89
+ }
90
+
91
+ def struct_fields; FIELDS; end
92
+
93
+ def validate
94
+ end
95
+
96
+ ::Thrift::Struct.generate_accessors self
97
+ end
98
+
99
+ class PutBar_args
100
+ include ::Thrift::Struct, ::Thrift::Struct_Union
101
+ BAR = 1
102
+
103
+ FIELDS = {
104
+ BAR => {:type => ::Thrift::Types::STRUCT, :name => 'bar', :class => ::Test::Bar}
105
+ }
106
+
107
+ def struct_fields; FIELDS; end
108
+
109
+ def validate
110
+ end
111
+
112
+ ::Thrift::Struct.generate_accessors self
113
+ end
114
+
115
+ class PutBar_result
116
+ include ::Thrift::Struct, ::Thrift::Struct_Union
117
+ SUCCESS = 0
118
+
119
+ FIELDS = {
120
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
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
+ end
132
+
133
+ end
@@ -0,0 +1,388 @@
1
+ #
2
+ # Autogenerated by Thrift Compiler (0.9.1)
3
+ #
4
+ # DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5
+ #
6
+
7
+ require 'thrift'
8
+ require 'foobar/foobar_types'
9
+
10
+ module Test
11
+ module CommonService
12
+ class Client
13
+ include ::Thrift::Client
14
+
15
+ def ping()
16
+ send_ping()
17
+ end
18
+
19
+ def send_ping()
20
+ send_message('ping', Ping_args)
21
+ end
22
+ def timeout()
23
+ send_timeout()
24
+ return recv_timeout()
25
+ end
26
+
27
+ def send_timeout()
28
+ send_message('timeout', Timeout_args)
29
+ end
30
+
31
+ def recv_timeout()
32
+ result = receive_message(Timeout_result)
33
+ return result.success unless result.success.nil?
34
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'timeout failed: unknown result')
35
+ end
36
+
37
+ def wait(seconds)
38
+ send_wait(seconds)
39
+ return recv_wait()
40
+ end
41
+
42
+ def send_wait(seconds)
43
+ send_message('wait', Wait_args, :seconds => seconds)
44
+ end
45
+
46
+ def recv_wait()
47
+ result = receive_message(Wait_result)
48
+ return result.success unless result.success.nil?
49
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'wait failed: unknown result')
50
+ end
51
+
52
+ def apperror()
53
+ send_apperror()
54
+ return recv_apperror()
55
+ end
56
+
57
+ def send_apperror()
58
+ send_message('apperror', Apperror_args)
59
+ end
60
+
61
+ def recv_apperror()
62
+ result = receive_message(Apperror_result)
63
+ return result.success unless result.success.nil?
64
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'apperror failed: unknown result')
65
+ end
66
+
67
+ def ptoerror()
68
+ send_ptoerror()
69
+ return recv_ptoerror()
70
+ end
71
+
72
+ def send_ptoerror()
73
+ send_message('ptoerror', Ptoerror_args)
74
+ end
75
+
76
+ def recv_ptoerror()
77
+ result = receive_message(Ptoerror_result)
78
+ return result.success unless result.success.nil?
79
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'ptoerror failed: unknown result')
80
+ end
81
+
82
+ def tranerror()
83
+ send_tranerror()
84
+ return recv_tranerror()
85
+ end
86
+
87
+ def send_tranerror()
88
+ send_message('tranerror', Tranerror_args)
89
+ end
90
+
91
+ def recv_tranerror()
92
+ result = receive_message(Tranerror_result)
93
+ return result.success unless result.success.nil?
94
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'tranerror failed: unknown result')
95
+ end
96
+
97
+ def ioerror()
98
+ send_ioerror()
99
+ return recv_ioerror()
100
+ end
101
+
102
+ def send_ioerror()
103
+ send_message('ioerror', Ioerror_args)
104
+ end
105
+
106
+ def recv_ioerror()
107
+ result = receive_message(Ioerror_result)
108
+ return result.success unless result.success.nil?
109
+ raise ::Thrift::ApplicationException.new(::Thrift::ApplicationException::MISSING_RESULT, 'ioerror failed: unknown result')
110
+ end
111
+
112
+ end
113
+
114
+ class Processor
115
+ include ::Thrift::Processor
116
+
117
+ def process_ping(seqid, iprot, oprot)
118
+ args = read_args(iprot, Ping_args)
119
+ @handler.ping()
120
+ return
121
+ end
122
+
123
+ def process_timeout(seqid, iprot, oprot)
124
+ args = read_args(iprot, Timeout_args)
125
+ result = Timeout_result.new()
126
+ result.success = @handler.timeout()
127
+ write_result(result, oprot, 'timeout', seqid)
128
+ end
129
+
130
+ def process_wait(seqid, iprot, oprot)
131
+ args = read_args(iprot, Wait_args)
132
+ result = Wait_result.new()
133
+ result.success = @handler.wait(args.seconds)
134
+ write_result(result, oprot, 'wait', seqid)
135
+ end
136
+
137
+ def process_apperror(seqid, iprot, oprot)
138
+ args = read_args(iprot, Apperror_args)
139
+ result = Apperror_result.new()
140
+ result.success = @handler.apperror()
141
+ write_result(result, oprot, 'apperror', seqid)
142
+ end
143
+
144
+ def process_ptoerror(seqid, iprot, oprot)
145
+ args = read_args(iprot, Ptoerror_args)
146
+ result = Ptoerror_result.new()
147
+ result.success = @handler.ptoerror()
148
+ write_result(result, oprot, 'ptoerror', seqid)
149
+ end
150
+
151
+ def process_tranerror(seqid, iprot, oprot)
152
+ args = read_args(iprot, Tranerror_args)
153
+ result = Tranerror_result.new()
154
+ result.success = @handler.tranerror()
155
+ write_result(result, oprot, 'tranerror', seqid)
156
+ end
157
+
158
+ def process_ioerror(seqid, iprot, oprot)
159
+ args = read_args(iprot, Ioerror_args)
160
+ result = Ioerror_result.new()
161
+ result.success = @handler.ioerror()
162
+ write_result(result, oprot, 'ioerror', seqid)
163
+ end
164
+
165
+ end
166
+
167
+ # HELPER FUNCTIONS AND STRUCTURES
168
+
169
+ class Ping_args
170
+ include ::Thrift::Struct, ::Thrift::Struct_Union
171
+
172
+ FIELDS = {
173
+
174
+ }
175
+
176
+ def struct_fields; FIELDS; end
177
+
178
+ def validate
179
+ end
180
+
181
+ ::Thrift::Struct.generate_accessors self
182
+ end
183
+
184
+ class Ping_result
185
+ include ::Thrift::Struct, ::Thrift::Struct_Union
186
+
187
+ FIELDS = {
188
+
189
+ }
190
+
191
+ def struct_fields; FIELDS; end
192
+
193
+ def validate
194
+ end
195
+
196
+ ::Thrift::Struct.generate_accessors self
197
+ end
198
+
199
+ class Timeout_args
200
+ include ::Thrift::Struct, ::Thrift::Struct_Union
201
+
202
+ FIELDS = {
203
+
204
+ }
205
+
206
+ def struct_fields; FIELDS; end
207
+
208
+ def validate
209
+ end
210
+
211
+ ::Thrift::Struct.generate_accessors self
212
+ end
213
+
214
+ class Timeout_result
215
+ include ::Thrift::Struct, ::Thrift::Struct_Union
216
+ SUCCESS = 0
217
+
218
+ FIELDS = {
219
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
220
+ }
221
+
222
+ def struct_fields; FIELDS; end
223
+
224
+ def validate
225
+ end
226
+
227
+ ::Thrift::Struct.generate_accessors self
228
+ end
229
+
230
+ class Wait_args
231
+ include ::Thrift::Struct, ::Thrift::Struct_Union
232
+ SECONDS = 1
233
+
234
+ FIELDS = {
235
+ SECONDS => {:type => ::Thrift::Types::I64, :name => 'seconds'}
236
+ }
237
+
238
+ def struct_fields; FIELDS; end
239
+
240
+ def validate
241
+ end
242
+
243
+ ::Thrift::Struct.generate_accessors self
244
+ end
245
+
246
+ class Wait_result
247
+ include ::Thrift::Struct, ::Thrift::Struct_Union
248
+ SUCCESS = 0
249
+
250
+ FIELDS = {
251
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
252
+ }
253
+
254
+ def struct_fields; FIELDS; end
255
+
256
+ def validate
257
+ end
258
+
259
+ ::Thrift::Struct.generate_accessors self
260
+ end
261
+
262
+ class Apperror_args
263
+ include ::Thrift::Struct, ::Thrift::Struct_Union
264
+
265
+ FIELDS = {
266
+
267
+ }
268
+
269
+ def struct_fields; FIELDS; end
270
+
271
+ def validate
272
+ end
273
+
274
+ ::Thrift::Struct.generate_accessors self
275
+ end
276
+
277
+ class Apperror_result
278
+ include ::Thrift::Struct, ::Thrift::Struct_Union
279
+ SUCCESS = 0
280
+
281
+ FIELDS = {
282
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
283
+ }
284
+
285
+ def struct_fields; FIELDS; end
286
+
287
+ def validate
288
+ end
289
+
290
+ ::Thrift::Struct.generate_accessors self
291
+ end
292
+
293
+ class Ptoerror_args
294
+ include ::Thrift::Struct, ::Thrift::Struct_Union
295
+
296
+ FIELDS = {
297
+
298
+ }
299
+
300
+ def struct_fields; FIELDS; end
301
+
302
+ def validate
303
+ end
304
+
305
+ ::Thrift::Struct.generate_accessors self
306
+ end
307
+
308
+ class Ptoerror_result
309
+ include ::Thrift::Struct, ::Thrift::Struct_Union
310
+ SUCCESS = 0
311
+
312
+ FIELDS = {
313
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
314
+ }
315
+
316
+ def struct_fields; FIELDS; end
317
+
318
+ def validate
319
+ end
320
+
321
+ ::Thrift::Struct.generate_accessors self
322
+ end
323
+
324
+ class Tranerror_args
325
+ include ::Thrift::Struct, ::Thrift::Struct_Union
326
+
327
+ FIELDS = {
328
+
329
+ }
330
+
331
+ def struct_fields; FIELDS; end
332
+
333
+ def validate
334
+ end
335
+
336
+ ::Thrift::Struct.generate_accessors self
337
+ end
338
+
339
+ class Tranerror_result
340
+ include ::Thrift::Struct, ::Thrift::Struct_Union
341
+ SUCCESS = 0
342
+
343
+ FIELDS = {
344
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
345
+ }
346
+
347
+ def struct_fields; FIELDS; end
348
+
349
+ def validate
350
+ end
351
+
352
+ ::Thrift::Struct.generate_accessors self
353
+ end
354
+
355
+ class Ioerror_args
356
+ include ::Thrift::Struct, ::Thrift::Struct_Union
357
+
358
+ FIELDS = {
359
+
360
+ }
361
+
362
+ def struct_fields; FIELDS; end
363
+
364
+ def validate
365
+ end
366
+
367
+ ::Thrift::Struct.generate_accessors self
368
+ end
369
+
370
+ class Ioerror_result
371
+ include ::Thrift::Struct, ::Thrift::Struct_Union
372
+ SUCCESS = 0
373
+
374
+ FIELDS = {
375
+ SUCCESS => {:type => ::Thrift::Types::BOOL, :name => 'success'}
376
+ }
377
+
378
+ def struct_fields; FIELDS; end
379
+
380
+ def validate
381
+ end
382
+
383
+ ::Thrift::Struct.generate_accessors self
384
+ end
385
+
386
+ end
387
+
388
+ end