thrift 0.9.2.0 → 0.15.0

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.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/ext/binary_protocol_accelerated.c +12 -12
  3. data/ext/compact_protocol.c +1 -0
  4. data/ext/struct.c +14 -1
  5. data/ext/thrift_native.c +17 -0
  6. data/lib/thrift/multiplexed_processor.rb +76 -0
  7. data/lib/thrift/processor.rb +24 -6
  8. data/lib/thrift/protocol/base_protocol.rb +11 -3
  9. data/lib/thrift/protocol/binary_protocol.rb +8 -1
  10. data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
  11. data/lib/thrift/protocol/compact_protocol.rb +8 -0
  12. data/lib/thrift/protocol/json_protocol.rb +21 -4
  13. data/lib/thrift/protocol/multiplexed_protocol.rb +44 -0
  14. data/lib/thrift/protocol/protocol_decorator.rb +194 -0
  15. data/lib/thrift/server/base_server.rb +8 -2
  16. data/lib/thrift/server/simple_server.rb +5 -1
  17. data/lib/thrift/server/thread_pool_server.rb +5 -1
  18. data/lib/thrift/server/threaded_server.rb +5 -1
  19. data/lib/thrift/transport/base_server_transport.rb +1 -1
  20. data/lib/thrift/transport/base_transport.rb +8 -0
  21. data/lib/thrift/transport/buffered_transport.rb +9 -1
  22. data/lib/thrift/transport/framed_transport.rb +9 -1
  23. data/lib/thrift/transport/http_client_transport.rb +7 -0
  24. data/lib/thrift/transport/io_stream_transport.rb +4 -1
  25. data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
  26. data/lib/thrift/transport/server_socket.rb +6 -1
  27. data/lib/thrift/transport/socket.rb +21 -17
  28. data/lib/thrift/transport/ssl_server_socket.rb +41 -0
  29. data/lib/thrift/transport/ssl_socket.rb +51 -0
  30. data/lib/thrift/transport/unix_server_socket.rb +5 -1
  31. data/lib/thrift/transport/unix_socket.rb +5 -1
  32. data/lib/thrift/union.rb +3 -6
  33. data/lib/thrift.rb +8 -4
  34. data/spec/BaseService.thrift +27 -0
  35. data/spec/ExtendedService.thrift +25 -0
  36. data/spec/base_protocol_spec.rb +79 -71
  37. data/spec/base_transport_spec.rb +155 -117
  38. data/spec/binary_protocol_accelerated_spec.rb +6 -2
  39. data/spec/binary_protocol_spec.rb +16 -8
  40. data/spec/binary_protocol_spec_shared.rb +75 -72
  41. data/spec/bytes_spec.rb +38 -38
  42. data/spec/client_spec.rb +41 -42
  43. data/spec/compact_protocol_spec.rb +32 -17
  44. data/spec/exception_spec.rb +54 -54
  45. data/spec/flat_spec.rb +62 -0
  46. data/spec/http_client_spec.rb +74 -33
  47. data/spec/json_protocol_spec.rb +170 -131
  48. data/spec/namespaced_spec.rb +10 -5
  49. data/spec/nonblocking_server_spec.rb +16 -16
  50. data/spec/processor_spec.rb +26 -26
  51. data/spec/serializer_spec.rb +20 -20
  52. data/spec/server_socket_spec.rb +27 -22
  53. data/spec/server_spec.rb +91 -51
  54. data/spec/socket_spec.rb +23 -16
  55. data/spec/socket_spec_shared.rb +31 -31
  56. data/spec/spec_helper.rb +9 -1
  57. data/spec/ssl_server_socket_spec.rb +34 -0
  58. data/spec/ssl_socket_spec.rb +78 -0
  59. data/spec/struct_nested_containers_spec.rb +24 -24
  60. data/spec/struct_spec.rb +120 -120
  61. data/spec/thin_http_server_spec.rb +18 -18
  62. data/spec/types_spec.rb +56 -53
  63. data/spec/union_spec.rb +51 -40
  64. data/spec/unix_socket_spec.rb +43 -34
  65. metadata +205 -143
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2f990b7528ad0c61eee1ef6fb2ff0cfc85c7f4912ec34eb6919e998f5dbbf016
4
+ data.tar.gz: d6958229cbc05dbe919746ec9019823635a29018e8f6c6542c5698bc61d5444a
5
+ SHA512:
6
+ metadata.gz: 649454979aca2efed3f750e6d81a5b4763e46d16ea2d7ae795401bca2ec94f4b4a93a8264bf010d3ff54674cb6f206d52a65a886b197dd9ae677a53ff835d79b
7
+ data.tar.gz: 3b257ad43df2146a8ee1bc96d06142476004de18af38080799fe197864cda0858479e18955d20f9dc271f9c40ec106783e87ece7bbc0c3ccba6c32dafda34707
@@ -283,27 +283,27 @@ VALUE rb_thrift_binary_proto_read_message_end(VALUE self) {
283
283
  return Qnil;
284
284
  }
285
285
 
286
- VALUE rb_thift_binary_proto_read_struct_begin(VALUE self) {
286
+ VALUE rb_thrift_binary_proto_read_struct_begin(VALUE self) {
287
287
  return Qnil;
288
288
  }
289
289
 
290
- VALUE rb_thift_binary_proto_read_struct_end(VALUE self) {
290
+ VALUE rb_thrift_binary_proto_read_struct_end(VALUE self) {
291
291
  return Qnil;
292
292
  }
293
293
 
294
- VALUE rb_thift_binary_proto_read_field_end(VALUE self) {
294
+ VALUE rb_thrift_binary_proto_read_field_end(VALUE self) {
295
295
  return Qnil;
296
296
  }
297
297
 
298
- VALUE rb_thift_binary_proto_read_map_end(VALUE self) {
298
+ VALUE rb_thrift_binary_proto_read_map_end(VALUE self) {
299
299
  return Qnil;
300
300
  }
301
301
 
302
- VALUE rb_thift_binary_proto_read_list_end(VALUE self) {
302
+ VALUE rb_thrift_binary_proto_read_list_end(VALUE self) {
303
303
  return Qnil;
304
304
  }
305
305
 
306
- VALUE rb_thift_binary_proto_read_set_end(VALUE self) {
306
+ VALUE rb_thrift_binary_proto_read_set_end(VALUE self) {
307
307
  return Qnil;
308
308
  }
309
309
 
@@ -449,12 +449,12 @@ void Init_binary_protocol_accelerated() {
449
449
  rb_define_method(bpa_class, "read_binary", rb_thrift_binary_proto_read_binary, 0);
450
450
  // unused methods
451
451
  rb_define_method(bpa_class, "read_message_end", rb_thrift_binary_proto_read_message_end, 0);
452
- rb_define_method(bpa_class, "read_struct_begin", rb_thift_binary_proto_read_struct_begin, 0);
453
- rb_define_method(bpa_class, "read_struct_end", rb_thift_binary_proto_read_struct_end, 0);
454
- rb_define_method(bpa_class, "read_field_end", rb_thift_binary_proto_read_field_end, 0);
455
- rb_define_method(bpa_class, "read_map_end", rb_thift_binary_proto_read_map_end, 0);
456
- rb_define_method(bpa_class, "read_list_end", rb_thift_binary_proto_read_list_end, 0);
457
- rb_define_method(bpa_class, "read_set_end", rb_thift_binary_proto_read_set_end, 0);
452
+ rb_define_method(bpa_class, "read_struct_begin", rb_thrift_binary_proto_read_struct_begin, 0);
453
+ rb_define_method(bpa_class, "read_struct_end", rb_thrift_binary_proto_read_struct_end, 0);
454
+ rb_define_method(bpa_class, "read_field_end", rb_thrift_binary_proto_read_field_end, 0);
455
+ rb_define_method(bpa_class, "read_map_end", rb_thrift_binary_proto_read_map_end, 0);
456
+ rb_define_method(bpa_class, "read_list_end", rb_thrift_binary_proto_read_list_end, 0);
457
+ rb_define_method(bpa_class, "read_set_end", rb_thrift_binary_proto_read_set_end, 0);
458
458
 
459
459
  rbuf_ivar_id = rb_intern("@rbuf");
460
460
  }
@@ -567,6 +567,7 @@ VALUE rb_thrift_compact_proto_read_binary(VALUE self) {
567
567
 
568
568
  static void Init_constants() {
569
569
  thrift_compact_protocol_class = rb_const_get(thrift_module, rb_intern("CompactProtocol"));
570
+ rb_global_variable(&thrift_compact_protocol_class);
570
571
 
571
572
  VERSION = rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("VERSION")));
572
573
  VERSION_MASK = rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("VERSION_MASK")));
data/ext/struct.c CHANGED
@@ -290,7 +290,7 @@ static void write_container(int ttype, VALUE field_info, VALUE value, VALUE prot
290
290
 
291
291
  if (TYPE(value) == T_ARRAY) {
292
292
  items = value;
293
- } else {
293
+ } else {
294
294
  if (rb_cSet == CLASS_OF(value)) {
295
295
  items = rb_funcall(value, entries_method_id, 0);
296
296
  } else {
@@ -670,6 +670,10 @@ static VALUE rb_thrift_union_write(VALUE self, VALUE protocol) {
670
670
 
671
671
  VALUE field_info = rb_hash_aref(struct_fields, field_id);
672
672
 
673
+ if(NIL_P(field_info)) {
674
+ rb_raise(rb_eRuntimeError, "set_field is not valid for this union!");
675
+ }
676
+
673
677
  VALUE ttype_value = rb_hash_aref(field_info, type_sym);
674
678
  int ttype = FIX2INT(ttype_value);
675
679
 
@@ -694,14 +698,23 @@ void Init_struct() {
694
698
  rb_define_method(struct_module, "read", rb_thrift_struct_read, 1);
695
699
 
696
700
  thrift_union_class = rb_const_get(thrift_module, rb_intern("Union"));
701
+ rb_global_variable(&thrift_union_class);
697
702
 
698
703
  rb_define_method(thrift_union_class, "write", rb_thrift_union_write, 1);
699
704
  rb_define_method(thrift_union_class, "read", rb_thrift_union_read, 1);
700
705
 
701
706
  setfield_id = rb_intern("@setfield");
707
+ rb_global_variable(&setfield_id);
708
+
702
709
  setvalue_id = rb_intern("@value");
710
+ rb_global_variable(&setvalue_id);
703
711
 
704
712
  to_s_method_id = rb_intern("to_s");
713
+ rb_global_variable(&to_s_method_id);
714
+
705
715
  name_to_id_method_id = rb_intern("name_to_id");
716
+ rb_global_variable(&name_to_id_method_id);
717
+
706
718
  sorted_field_ids_method_id = rb_intern("sorted_field_ids");
719
+ rb_global_variable(&sorted_field_ids_method_id);
707
720
  }
data/ext/thrift_native.c CHANGED
@@ -112,10 +112,19 @@ VALUE protocol_exception_class;
112
112
  void Init_thrift_native() {
113
113
  // cached classes
114
114
  thrift_module = rb_const_get(rb_cObject, rb_intern("Thrift"));
115
+ rb_global_variable(&thrift_module);
116
+
115
117
  thrift_bytes_module = rb_const_get(thrift_module, rb_intern("Bytes"));
118
+ rb_global_variable(&thrift_bytes_module);
119
+
116
120
  thrift_types_module = rb_const_get(thrift_module, rb_intern("Types"));
121
+ rb_global_variable(&thrift_types_module);
122
+
117
123
  rb_cSet = rb_const_get(rb_cObject, rb_intern("Set"));
124
+ rb_global_variable(&rb_cSet);
125
+
118
126
  protocol_exception_class = rb_const_get(thrift_module, rb_intern("ProtocolException"));
127
+ rb_global_variable(&protocol_exception_class);
119
128
 
120
129
  // Init ttype constants
121
130
  TTYPE_BOOL = FIX2INT(rb_const_get(thrift_types_module, rb_intern("BOOL")));
@@ -194,6 +203,14 @@ void Init_thrift_native() {
194
203
  class_sym = ID2SYM(rb_intern("class"));
195
204
  binary_sym = ID2SYM(rb_intern("binary"));
196
205
 
206
+ rb_global_variable(&type_sym);
207
+ rb_global_variable(&name_sym);
208
+ rb_global_variable(&key_sym);
209
+ rb_global_variable(&value_sym);
210
+ rb_global_variable(&element_sym);
211
+ rb_global_variable(&class_sym);
212
+ rb_global_variable(&binary_sym);
213
+
197
214
  Init_struct();
198
215
  Init_binary_protocol_accelerated();
199
216
  Init_compact_protocol();
@@ -0,0 +1,76 @@
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
+ require 'thrift/protocol/protocol_decorator'
20
+ require 'thrift/protocol/base_protocol'
21
+
22
+ module Thrift
23
+ class MultiplexedProcessor
24
+ def initialize
25
+ @actual_processors = {}
26
+ end
27
+
28
+ def register_processor(service_name, processor)
29
+ @actual_processors[service_name] = processor
30
+ end
31
+
32
+ def process(iprot, oprot)
33
+ name, type, seqid = iprot.read_message_begin
34
+ check_type(type)
35
+ check_separator(name)
36
+ service_name, method = name.split(':')
37
+ processor(service_name).process(StoredMessageProtocol.new(iprot, [method, type, seqid]), oprot)
38
+ end
39
+
40
+ protected
41
+
42
+ def processor(service_name)
43
+ if @actual_processors.has_key?(service_name)
44
+ @actual_processors[service_name]
45
+ else
46
+ raise Thrift::Exception.new("Service name not found: #{service_name}. Did you forget to call #{self.class.name}#register_processor?")
47
+ end
48
+ end
49
+
50
+ def check_type(type)
51
+ unless [MessageTypes::CALL, MessageTypes::ONEWAY].include?(type)
52
+ raise Thrift::Exception.new('This should not have happened!?')
53
+ end
54
+ end
55
+
56
+ def check_separator(name)
57
+ if name.count(':') < 1
58
+ raise Thrift::Exception.new("Service name not found in message name: #{name}. Did you forget to use a Thrift::Protocol::MultiplexedProtocol in your client?")
59
+ end
60
+ end
61
+ end
62
+
63
+ class StoredMessageProtocol < BaseProtocol
64
+
65
+ include ProtocolDecorator
66
+
67
+ def initialize(protocol, message_begin)
68
+ super(protocol)
69
+ @message_begin = message_begin
70
+ end
71
+
72
+ def read_message_begin
73
+ @message_begin
74
+ end
75
+ end
76
+ end
@@ -17,25 +17,36 @@
17
17
  # under the License.
18
18
  #
19
19
 
20
+ require 'logger'
21
+
20
22
  module Thrift
21
23
  module Processor
22
- def initialize(handler)
24
+ def initialize(handler, logger=nil)
23
25
  @handler = handler
26
+ if logger.nil?
27
+ @logger = Logger.new(STDERR)
28
+ @logger.level = Logger::WARN
29
+ else
30
+ @logger = logger
31
+ end
24
32
  end
25
33
 
26
34
  def process(iprot, oprot)
27
35
  name, type, seqid = iprot.read_message_begin
28
36
  if respond_to?("process_#{name}")
29
- send("process_#{name}", seqid, iprot, oprot)
37
+ begin
38
+ send("process_#{name}", seqid, iprot, oprot)
39
+ rescue => e
40
+ x = ApplicationException.new(ApplicationException::INTERNAL_ERROR, 'Internal error')
41
+ @logger.debug "Internal error : #{e.message}\n#{e.backtrace.join("\n")}"
42
+ write_error(x, oprot, name, seqid)
43
+ end
30
44
  true
31
45
  else
32
46
  iprot.skip(Types::STRUCT)
33
47
  iprot.read_message_end
34
48
  x = ApplicationException.new(ApplicationException::UNKNOWN_METHOD, 'Unknown function '+name)
35
- oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
36
- x.write(oprot)
37
- oprot.write_message_end
38
- oprot.trans.flush
49
+ write_error(x, oprot, name, seqid)
39
50
  false
40
51
  end
41
52
  end
@@ -53,5 +64,12 @@ module Thrift
53
64
  oprot.write_message_end
54
65
  oprot.trans.flush
55
66
  end
67
+
68
+ def write_error(err, oprot, name, seqid)
69
+ oprot.write_message_begin(name, MessageTypes::EXCEPTION, seqid)
70
+ err.write(oprot)
71
+ oprot.write_message_end
72
+ oprot.trans.flush
73
+ end
56
74
  end
57
75
  end
@@ -323,8 +323,6 @@ module Thrift
323
323
 
324
324
  def skip(type)
325
325
  case type
326
- when Types::STOP
327
- nil
328
326
  when Types::BOOL
329
327
  read_bool
330
328
  when Types::BYTE
@@ -367,13 +365,23 @@ module Thrift
367
365
  skip(etype)
368
366
  end
369
367
  read_list_end
368
+ else
369
+ raise ProtocolException.new(ProtocolException::INVALID_DATA, 'Invalid data')
370
370
  end
371
371
  end
372
+
373
+ def to_s
374
+ "#{trans.to_s}"
375
+ end
372
376
  end
373
377
 
374
378
  class BaseProtocolFactory
375
379
  def get_protocol(trans)
376
380
  raise NotImplementedError
377
381
  end
382
+
383
+ def to_s
384
+ "base"
385
+ end
378
386
  end
379
- end
387
+ end
@@ -226,12 +226,19 @@ module Thrift
226
226
  size = read_i32
227
227
  trans.read_all(size)
228
228
  end
229
-
229
+
230
+ def to_s
231
+ "binary(#{super.to_s})"
232
+ end
230
233
  end
231
234
 
232
235
  class BinaryProtocolFactory < BaseProtocolFactory
233
236
  def get_protocol(trans)
234
237
  return Thrift::BinaryProtocol.new(trans)
235
238
  end
239
+
240
+ def to_s
241
+ "binary"
242
+ end
236
243
  end
237
244
  end
@@ -35,5 +35,13 @@ module Thrift
35
35
  BinaryProtocol.new(trans)
36
36
  end
37
37
  end
38
+
39
+ def to_s
40
+ if (defined? BinaryProtocolAccelerated)
41
+ "binary-accel"
42
+ else
43
+ "binary"
44
+ end
45
+ end
38
46
  end
39
47
  end
@@ -345,6 +345,10 @@ module Thrift
345
345
  size = read_varint32()
346
346
  trans.read_all(size)
347
347
  end
348
+
349
+ def to_s
350
+ "compact(#{super.to_s})"
351
+ end
348
352
 
349
353
  private
350
354
 
@@ -431,5 +435,9 @@ module Thrift
431
435
  def get_protocol(trans)
432
436
  CompactProtocol.new(trans)
433
437
  end
438
+
439
+ def to_s
440
+ "compact"
441
+ end
434
442
  end
435
443
  end
@@ -18,6 +18,7 @@
18
18
  # under the License.
19
19
  #
20
20
 
21
+ require 'base64'
21
22
 
22
23
  module Thrift
23
24
  class LookaheadReader
@@ -310,7 +311,7 @@ module Thrift
310
311
  def write_json_base64(str)
311
312
  @context.write(trans)
312
313
  trans.write(@@kJSONStringDelimiter)
313
- write_json_string([str].pack("m"))
314
+ trans.write(Base64.strict_encode64(str))
314
315
  trans.write(@@kJSONStringDelimiter)
315
316
  end
316
317
 
@@ -332,7 +333,7 @@ module Thrift
332
333
  # "NaN" or "Infinity" or "-Infinity".
333
334
  def write_json_double(num)
334
335
  @context.write(trans)
335
- # Normalize output of boost::lexical_cast for NaNs and Infinities
336
+ # Normalize output of thrift::to_string for NaNs and Infinities
336
337
  special = false;
337
338
  if (num.nan?)
338
339
  special = true;
@@ -513,7 +514,7 @@ module Thrift
513
514
  # The elements of this array must match up with the sequence of characters in
514
515
  # escape_chars
515
516
  escape_char_vals = [
516
- '"', '\\', '/', '\b', '\f', '\n', '\r', '\t',
517
+ "\"", "\\", "\/", "\b", "\f", "\n", "\r", "\t",
517
518
  ]
518
519
 
519
520
  if !skipContext
@@ -546,7 +547,15 @@ module Thrift
546
547
 
547
548
  # Reads a block of base64 characters, decoding it, and returns via str
548
549
  def read_json_base64
549
- read_json_string.unpack("m")[0]
550
+ str = read_json_string
551
+ m = str.length % 4
552
+ if m != 0
553
+ # Add missing padding
554
+ (4 - m).times do
555
+ str += '='
556
+ end
557
+ end
558
+ Base64.strict_decode64(str)
550
559
  end
551
560
 
552
561
  # Reads a sequence of characters, stopping at the first one that is not
@@ -759,11 +768,19 @@ module Thrift
759
768
  def read_binary
760
769
  read_json_base64
761
770
  end
771
+
772
+ def to_s
773
+ "json(#{super.to_s})"
774
+ end
762
775
  end
763
776
 
764
777
  class JsonProtocolFactory < BaseProtocolFactory
765
778
  def get_protocol(trans)
766
779
  return Thrift::JsonProtocol.new(trans)
767
780
  end
781
+
782
+ def to_s
783
+ "json"
784
+ end
768
785
  end
769
786
  end
@@ -0,0 +1,44 @@
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
+ require 'thrift/protocol/protocol_decorator'
20
+
21
+ module Thrift
22
+ class MultiplexedProtocol < BaseProtocol
23
+
24
+ include ProtocolDecorator
25
+
26
+ def initialize(protocol, service_name)
27
+ super(protocol)
28
+ @service_name = service_name
29
+ end
30
+
31
+ def write_message_begin(name, type, seqid)
32
+ case type
33
+ when MessageTypes::CALL, MessageTypes::ONEWAY
34
+ @protocol.write_message_begin("#{@service_name}:#{name}", type, seqid)
35
+ else
36
+ @protocol.write_message_begin(name, type, seqid)
37
+ end
38
+ end
39
+
40
+ def to_s
41
+ "multiplexed(#{@service_name=@protocol.to_s})"
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,194 @@
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
+ module Thrift
20
+ module ProtocolDecorator
21
+
22
+ def initialize(protocol)
23
+ @protocol = protocol
24
+ end
25
+
26
+ def trans
27
+ @protocol.trans
28
+ end
29
+
30
+ def write_message_begin(name, type, seqid)
31
+ @protocol.write_message_begin
32
+ end
33
+
34
+ def write_message_end
35
+ @protocol.write_message_end
36
+ end
37
+
38
+ def write_struct_begin(name)
39
+ @protocol.write_struct_begin(name)
40
+ end
41
+
42
+ def write_struct_end
43
+ @protocol.write_struct_end
44
+ end
45
+
46
+ def write_field_begin(name, type, id)
47
+ @protocol.write_field_begin(name, type, id)
48
+ end
49
+
50
+ def write_field_end
51
+ @protocol.write_field_end
52
+ end
53
+
54
+ def write_field_stop
55
+ @protocol.write_field_stop
56
+ end
57
+
58
+ def write_map_begin(ktype, vtype, size)
59
+ @protocol.write_map_begin(ktype, vtype, size)
60
+ end
61
+
62
+ def write_map_end
63
+ @protocol.write_map_end
64
+ end
65
+
66
+ def write_list_begin(etype, size)
67
+ @protocol.write_list_begin(etype, size)
68
+ end
69
+
70
+ def write_list_end
71
+ @protocol.write_list_end
72
+ end
73
+
74
+ def write_set_begin(etype, size)
75
+ @protocol.write_set_begin(etype, size)
76
+ end
77
+
78
+ def write_set_end
79
+ @protocol.write_set_end
80
+ end
81
+
82
+ def write_bool(bool)
83
+ @protocol.write_bool(bool)
84
+ end
85
+
86
+ def write_byte(byte)
87
+ @protocol.write_byte(byte)
88
+ end
89
+
90
+ def write_i16(i16)
91
+ @protocol.write_i16(i16)
92
+ end
93
+
94
+ def write_i32(i32)
95
+ @protocol.write_i32(i32)
96
+ end
97
+
98
+ def write_i64(i64)
99
+ @protocol.write_i64(i64)
100
+ end
101
+
102
+ def write_double(dub)
103
+ @protocol.write_double(dub)
104
+ end
105
+
106
+ def write_string(str)
107
+ @protocol.write_string(str)
108
+ end
109
+
110
+ def write_binary(buf)
111
+ @protocol.write_binary(buf)
112
+ end
113
+
114
+ def read_message_begin
115
+ @protocol.read_message_begin
116
+ end
117
+
118
+ def read_message_end
119
+ @protocol.read_message_end
120
+ end
121
+
122
+ def read_struct_begin
123
+ @protocol.read_struct_begin
124
+ end
125
+
126
+ def read_struct_end
127
+ @protocol.read_struct_end
128
+ end
129
+
130
+ def read_field_begin
131
+ @protocol.read_field_begin
132
+ end
133
+
134
+ def read_field_end
135
+ @protocol.read_field_end
136
+ end
137
+
138
+ def read_map_begin
139
+ @protocol.read_map_begin
140
+ end
141
+
142
+ def read_map_end
143
+ @protocol.read_map_end
144
+ end
145
+
146
+ def read_list_begin
147
+ @protocol.read_list_begin
148
+ end
149
+
150
+ def read_list_end
151
+ @protocol.read_list_end
152
+ end
153
+
154
+ def read_set_begin
155
+ @protocol.read_set_begin
156
+ end
157
+
158
+ def read_set_end
159
+ @protocol.read_set_end
160
+ end
161
+
162
+ def read_bool
163
+ @protocol.read_bool
164
+ end
165
+
166
+ def read_byte
167
+ @protocol.read_byte
168
+ end
169
+
170
+ def read_i16
171
+ @protocol.read_i16
172
+ end
173
+
174
+ def read_i32
175
+ @protocol.read_i32
176
+ end
177
+
178
+ def read_i64
179
+ @protocol.read_i64
180
+ end
181
+
182
+ def read_double
183
+ @protocol.read_double
184
+ end
185
+
186
+ def read_string
187
+ @protocol.read_string
188
+ end
189
+
190
+ def read_binary
191
+ @protocol.read_binary
192
+ end
193
+ end
194
+ end
@@ -26,6 +26,12 @@ module Thrift
26
26
  @protocol_factory = protocol_factory ? protocol_factory : Thrift::BinaryProtocolFactory.new
27
27
  end
28
28
 
29
- def serve; nil; end
29
+ def serve
30
+ raise NotImplementedError
31
+ end
32
+
33
+ def to_s
34
+ "server(#{@protocol_factory.to_s}(#{@transport_factory.to_s}(#{@server_transport.to_s})))"
35
+ end
30
36
  end
31
- end
37
+ end