thrift 0.11.0.0 → 0.22.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 (89) hide show
  1. checksums.yaml +5 -5
  2. data/ext/binary_protocol_accelerated.c +5 -5
  3. data/ext/compact_protocol.c +10 -9
  4. data/ext/memory_buffer.c +1 -1
  5. data/ext/struct.c +10 -1
  6. data/ext/thrift_native.c +17 -0
  7. data/lib/thrift/client.rb +10 -2
  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 +8 -0
  13. data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
  14. data/lib/thrift/server/base_server.rb +8 -2
  15. data/lib/thrift/server/simple_server.rb +5 -1
  16. data/lib/thrift/server/thread_pool_server.rb +5 -1
  17. data/lib/thrift/server/threaded_server.rb +5 -1
  18. data/lib/thrift/transport/base_server_transport.rb +1 -1
  19. data/lib/thrift/transport/base_transport.rb +8 -0
  20. data/lib/thrift/transport/buffered_transport.rb +9 -1
  21. data/lib/thrift/transport/framed_transport.rb +9 -1
  22. data/lib/thrift/transport/http_client_transport.rb +6 -0
  23. data/lib/thrift/transport/io_stream_transport.rb +4 -1
  24. data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
  25. data/lib/thrift/transport/server_socket.rb +6 -1
  26. data/lib/thrift/transport/socket.rb +4 -2
  27. data/lib/thrift/transport/ssl_server_socket.rb +4 -0
  28. data/lib/thrift/transport/ssl_socket.rb +4 -0
  29. data/lib/thrift/transport/unix_server_socket.rb +5 -1
  30. data/lib/thrift/transport/unix_socket.rb +5 -1
  31. data/spec/base_protocol_spec.rb +79 -71
  32. data/spec/base_transport_spec.rb +155 -117
  33. data/spec/binary_protocol_accelerated_spec.rb +6 -2
  34. data/spec/binary_protocol_spec.rb +16 -8
  35. data/spec/binary_protocol_spec_shared.rb +73 -70
  36. data/spec/bytes_spec.rb +38 -38
  37. data/spec/client_spec.rb +43 -42
  38. data/spec/compact_protocol_spec.rb +23 -8
  39. data/spec/exception_spec.rb +54 -54
  40. data/spec/flat_spec.rb +5 -5
  41. data/spec/http_client_spec.rb +64 -38
  42. data/spec/json_protocol_spec.rb +146 -138
  43. data/spec/namespaced_spec.rb +5 -5
  44. data/spec/nonblocking_server_spec.rb +16 -16
  45. data/spec/processor_spec.rb +26 -26
  46. data/spec/serializer_spec.rb +20 -20
  47. data/spec/server_socket_spec.rb +27 -22
  48. data/spec/server_spec.rb +91 -52
  49. data/spec/socket_spec.rb +23 -16
  50. data/spec/socket_spec_shared.rb +31 -31
  51. data/spec/spec_helper.rb +5 -0
  52. data/spec/ssl_server_socket_spec.rb +34 -0
  53. data/spec/ssl_socket_spec.rb +26 -22
  54. data/spec/struct_nested_containers_spec.rb +24 -24
  55. data/spec/struct_spec.rb +120 -120
  56. data/spec/thin_http_server_spec.rb +18 -18
  57. data/spec/types_spec.rb +56 -53
  58. data/spec/union_spec.rb +42 -43
  59. data/spec/unix_socket_spec.rb +43 -34
  60. metadata +152 -159
  61. data/benchmark/gen-rb/benchmark_constants.rb +0 -11
  62. data/benchmark/gen-rb/benchmark_service.rb +0 -80
  63. data/benchmark/gen-rb/benchmark_types.rb +0 -10
  64. data/spec/gen-rb/base/base_service.rb +0 -80
  65. data/spec/gen-rb/base/base_service_constants.rb +0 -11
  66. data/spec/gen-rb/base/base_service_types.rb +0 -26
  67. data/spec/gen-rb/extended/extended_service.rb +0 -78
  68. data/spec/gen-rb/extended/extended_service_constants.rb +0 -11
  69. data/spec/gen-rb/extended/extended_service_types.rb +0 -12
  70. data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +0 -272
  71. data/spec/gen-rb/flat/referenced_constants.rb +0 -11
  72. data/spec/gen-rb/flat/referenced_types.rb +0 -17
  73. data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +0 -11
  74. data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +0 -28
  75. data/spec/gen-rb/namespaced_spec_namespace/namespaced_nonblocking_service.rb +0 -272
  76. data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +0 -11
  77. data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +0 -28
  78. data/spec/gen-rb/nonblocking_service.rb +0 -272
  79. data/spec/gen-rb/other_namespace/referenced_constants.rb +0 -11
  80. data/spec/gen-rb/other_namespace/referenced_types.rb +0 -17
  81. data/spec/gen-rb/thrift_spec_constants.rb +0 -11
  82. data/spec/gen-rb/thrift_spec_types.rb +0 -538
  83. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +0 -278
  84. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +0 -781
  85. data/test/debug_proto/gen-rb/empty_service.rb +0 -28
  86. data/test/debug_proto/gen-rb/inherited.rb +0 -83
  87. data/test/debug_proto/gen-rb/reverse_order_service.rb +0 -86
  88. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +0 -85
  89. data/test/debug_proto/gen-rb/srv.rb +0 -395
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a9a70c3d1662d7eacf0ec7062e1134d679ebc085
4
- data.tar.gz: b65b2bbb34d616676940087447e47d487cdb815c
2
+ SHA256:
3
+ metadata.gz: fe32174805f7e6b9801ebf00500fad76c1922c3f5e816fba597dfc0aae195c5d
4
+ data.tar.gz: b908a7a66b4bff7fc95728778240d2583d685f2fdcdf563edb125dc571cb0040
5
5
  SHA512:
6
- metadata.gz: 4cc1765c1335c36c4473563bab2ef2eacf27540414251e3b94e7b0a0e9ac9a0f637e75f5c64f69b0028c2c402b08d8916d0fb29897f0da37f837d42b07fcac66
7
- data.tar.gz: 54fdb5210b5f850b4fd1fb6741dbac719d3ad340bcc94b2db8965b807ae701fad140961303f2bb52cd9f10bba2bd9c80d83b1682c9b70e3b15c271faf6e13049
6
+ metadata.gz: cd8377282c40257b9d4bd2e95633584a04f27609118a8694d9a0037cbf9affc4d9f42aa4647c4dcd43ed64668a77f7abb375f77ca6e5bef8aaae03db8702dcd8
7
+ data.tar.gz: 31637b8001126ee81c9a74803e2cbb942cb57dfbc529a72ceb121a28a2614695689d55bd0204dc12429d82ce38a7c0057c18420a872921f376e20e178b213c5e
@@ -82,7 +82,7 @@ static void write_string_direct(VALUE trans, VALUE str) {
82
82
  rb_raise(rb_eStandardError, "Value should be a string");
83
83
  }
84
84
  str = convert_to_utf8_byte_buffer(str);
85
- write_i32_direct(trans, RSTRING_LEN(str));
85
+ write_i32_direct(trans, (int32_t)RSTRING_LEN(str));
86
86
  rb_funcall(trans, write_method_id, 1, str);
87
87
  }
88
88
 
@@ -223,7 +223,7 @@ VALUE rb_thrift_binary_proto_write_binary(VALUE self, VALUE buf) {
223
223
  CHECK_NIL(buf);
224
224
  VALUE trans = GET_TRANSPORT(self);
225
225
  buf = force_binary_encoding(buf);
226
- write_i32_direct(trans, RSTRING_LEN(buf));
226
+ write_i32_direct(trans, (int32_t)RSTRING_LEN(buf));
227
227
  rb_funcall(trans, write_method_id, 1, buf);
228
228
  return Qnil;
229
229
  }
@@ -403,9 +403,9 @@ VALUE rb_thrift_binary_proto_read_binary(VALUE self) {
403
403
  void Init_binary_protocol_accelerated() {
404
404
  VALUE thrift_binary_protocol_class = rb_const_get(thrift_module, rb_intern("BinaryProtocol"));
405
405
 
406
- VERSION_1 = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_1")));
407
- VERSION_MASK = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_MASK")));
408
- TYPE_MASK = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("TYPE_MASK")));
406
+ VERSION_1 = (int)rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_1")));
407
+ VERSION_MASK = (int)rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_MASK")));
408
+ TYPE_MASK = (int)rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("TYPE_MASK")));
409
409
 
410
410
  VALUE bpa_class = rb_define_class_under(thrift_module, "BinaryProtocolAccelerated", thrift_binary_protocol_class);
411
411
 
@@ -315,7 +315,7 @@ VALUE rb_thrift_compact_proto_write_string(VALUE self, VALUE str) {
315
315
  VALUE rb_thrift_compact_proto_write_binary(VALUE self, VALUE buf) {
316
316
  buf = force_binary_encoding(buf);
317
317
  VALUE transport = GET_TRANSPORT(self);
318
- write_varint32(transport, RSTRING_LEN(buf));
318
+ write_varint32(transport, (uint32_t)RSTRING_LEN(buf));
319
319
  WRITE(transport, StringValuePtr(buf), RSTRING_LEN(buf));
320
320
  return Qnil;
321
321
  }
@@ -452,7 +452,7 @@ VALUE rb_thrift_compact_proto_read_message_begin(VALUE self) {
452
452
  }
453
453
 
454
454
  int8_t type = (version_and_type >> TYPE_SHIFT_AMOUNT) & TYPE_BITS;
455
- int32_t seqid = read_varint64(self);
455
+ int32_t seqid = (int32_t)read_varint64(self);
456
456
  VALUE messageName = rb_thrift_compact_proto_read_string(self);
457
457
  return rb_ary_new3(3, messageName, INT2FIX(type), INT2NUM(seqid));
458
458
  }
@@ -490,7 +490,7 @@ VALUE rb_thrift_compact_proto_read_field_begin(VALUE self) {
490
490
  }
491
491
 
492
492
  VALUE rb_thrift_compact_proto_read_map_begin(VALUE self) {
493
- int32_t size = read_varint64(self);
493
+ int32_t size = (int32_t)read_varint64(self);
494
494
  uint8_t key_and_value_type = size == 0 ? 0 : read_byte_direct(self);
495
495
  return rb_ary_new3(3, INT2FIX(get_ttype(key_and_value_type >> 4)), INT2FIX(get_ttype(key_and_value_type & 0xf)), INT2FIX(size));
496
496
  }
@@ -499,7 +499,7 @@ VALUE rb_thrift_compact_proto_read_list_begin(VALUE self) {
499
499
  uint8_t size_and_type = read_byte_direct(self);
500
500
  int32_t size = (size_and_type >> 4) & 0x0f;
501
501
  if (size == 15) {
502
- size = read_varint64(self);
502
+ size = (int32_t)read_varint64(self);
503
503
  }
504
504
  uint8_t type = get_ttype(size_and_type & 0x0f);
505
505
  return rb_ary_new3(2, INT2FIX(type), INT2FIX(size));
@@ -528,7 +528,7 @@ VALUE rb_thrift_compact_proto_read_i16(VALUE self) {
528
528
  }
529
529
 
530
530
  VALUE rb_thrift_compact_proto_read_i32(VALUE self) {
531
- return INT2NUM(zig_zag_to_int(read_varint64(self)));
531
+ return INT2NUM(zig_zag_to_int((int32_t)read_varint64(self)));
532
532
  }
533
533
 
534
534
  VALUE rb_thrift_compact_proto_read_i64(VALUE self) {
@@ -567,11 +567,12 @@ 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
- VERSION = rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("VERSION")));
572
- VERSION_MASK = rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("VERSION_MASK")));
573
- TYPE_MASK = rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("TYPE_MASK")));
574
- TYPE_BITS = rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("TYPE_BITS")));
572
+ VERSION = (int32_t)rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("VERSION")));
573
+ VERSION_MASK = (int32_t)rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("VERSION_MASK")));
574
+ TYPE_MASK = (int32_t)rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("TYPE_MASK")));
575
+ TYPE_BITS = (int32_t)rb_num2ll(rb_const_get(thrift_compact_protocol_class, rb_intern("TYPE_BITS")));
575
576
  TYPE_SHIFT_AMOUNT = FIX2INT(rb_const_get(thrift_compact_protocol_class, rb_intern("TYPE_SHIFT_AMOUNT")));
576
577
  PROTOCOL_ID = FIX2INT(rb_const_get(thrift_compact_protocol_class, rb_intern("PROTOCOL_ID")));
577
578
 
data/ext/memory_buffer.c CHANGED
@@ -54,7 +54,7 @@ VALUE rb_thrift_memory_buffer_read(VALUE self, VALUE length_value) {
54
54
 
55
55
  index += length;
56
56
  if (index > RSTRING_LEN(buf)) {
57
- index = RSTRING_LEN(buf);
57
+ index = (int)RSTRING_LEN(buf);
58
58
  }
59
59
  if (index >= GARBAGE_BUFFER_SIZE) {
60
60
  rb_ivar_set(self, buf_ivar_id, rb_funcall(buf, slice_method_id, 2, INT2FIX(index), INT2FIX(RSTRING_LEN(buf) - 1)));
data/ext/struct.c CHANGED
@@ -225,7 +225,7 @@ VALUE get_field_value(VALUE obj, VALUE field_name) {
225
225
  }
226
226
 
227
227
  static void write_container(int ttype, VALUE field_info, VALUE value, VALUE protocol) {
228
- int sz, i;
228
+ long sz, i;
229
229
 
230
230
  if (ttype == TTYPE_MAP) {
231
231
  VALUE keys;
@@ -698,14 +698,23 @@ void Init_struct() {
698
698
  rb_define_method(struct_module, "read", rb_thrift_struct_read, 1);
699
699
 
700
700
  thrift_union_class = rb_const_get(thrift_module, rb_intern("Union"));
701
+ rb_global_variable(&thrift_union_class);
701
702
 
702
703
  rb_define_method(thrift_union_class, "write", rb_thrift_union_write, 1);
703
704
  rb_define_method(thrift_union_class, "read", rb_thrift_union_read, 1);
704
705
 
705
706
  setfield_id = rb_intern("@setfield");
707
+ rb_global_variable(&setfield_id);
708
+
706
709
  setvalue_id = rb_intern("@value");
710
+ rb_global_variable(&setvalue_id);
707
711
 
708
712
  to_s_method_id = rb_intern("to_s");
713
+ rb_global_variable(&to_s_method_id);
714
+
709
715
  name_to_id_method_id = rb_intern("name_to_id");
716
+ rb_global_variable(&name_to_id_method_id);
717
+
710
718
  sorted_field_ids_method_id = rb_intern("sorted_field_ids");
719
+ rb_global_variable(&sorted_field_ids_method_id);
711
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();
data/lib/thrift/client.rb CHANGED
@@ -50,9 +50,17 @@ module Thrift
50
50
  @oprot.trans.flush
51
51
  end
52
52
 
53
- def receive_message(result_klass)
53
+ def receive_message_begin()
54
54
  fname, mtype, rseqid = @iprot.read_message_begin
55
- handle_exception(mtype)
55
+ [fname, mtype, rseqid]
56
+ end
57
+
58
+ def reply_seqid(rseqid)
59
+ result = (rseqid==@seqid)?true:false
60
+ result
61
+ end
62
+
63
+ def receive_message(result_klass)
56
64
  result = result_klass.new
57
65
  result.read(@iprot)
58
66
  @iprot.read_message_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
@@ -768,11 +768,19 @@ module Thrift
768
768
  def read_binary
769
769
  read_json_base64
770
770
  end
771
+
772
+ def to_s
773
+ "json(#{super.to_s})"
774
+ end
771
775
  end
772
776
 
773
777
  class JsonProtocolFactory < BaseProtocolFactory
774
778
  def get_protocol(trans)
775
779
  return Thrift::JsonProtocol.new(trans)
776
780
  end
781
+
782
+ def to_s
783
+ "json"
784
+ end
777
785
  end
778
786
  end
@@ -36,5 +36,9 @@ module Thrift
36
36
  @protocol.write_message_begin(name, type, seqid)
37
37
  end
38
38
  end
39
+
40
+ def to_s
41
+ "multiplexed(#{@service_name=@protocol.to_s})"
42
+ end
39
43
  end
40
- end
44
+ 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
@@ -39,5 +39,9 @@ module Thrift
39
39
  @server_transport.close
40
40
  end
41
41
  end
42
+
43
+ def to_s
44
+ "simple(#{super.to_s})"
45
+ end
42
46
  end
43
- end
47
+ end
@@ -71,5 +71,9 @@ module Thrift
71
71
  @server_transport.close
72
72
  end
73
73
  end
74
+
75
+ def to_s
76
+ "threadpool(#{super.to_s})"
77
+ end
74
78
  end
75
- end
79
+ end
@@ -43,5 +43,9 @@ module Thrift
43
43
  @server_transport.close
44
44
  end
45
45
  end
46
+
47
+ def to_s
48
+ "threaded(#{super.to_s})"
49
+ end
46
50
  end
47
- end
51
+ end
@@ -34,4 +34,4 @@ module Thrift
34
34
  raise NotImplementedError
35
35
  end
36
36
  end
37
- end
37
+ end
@@ -99,11 +99,19 @@ module Thrift
99
99
  alias_method :<<, :write
100
100
 
101
101
  def flush; end
102
+
103
+ def to_s
104
+ "base"
105
+ end
102
106
  end
103
107
 
104
108
  class BaseTransportFactory
105
109
  def get_transport(trans)
106
110
  return trans
107
111
  end
112
+
113
+ def to_s
114
+ "base"
115
+ end
108
116
  end
109
117
  end
@@ -104,11 +104,19 @@ module Thrift
104
104
 
105
105
  @transport.flush
106
106
  end
107
+
108
+ def to_s
109
+ "buffered(#{@transport.to_s})"
110
+ end
107
111
  end
108
112
 
109
113
  class BufferedTransportFactory < BaseTransportFactory
110
114
  def get_transport(transport)
111
115
  return BufferedTransport.new(transport)
112
116
  end
117
+
118
+ def to_s
119
+ "buffered"
120
+ end
113
121
  end
114
- end
122
+ end
@@ -99,6 +99,10 @@ module Thrift
99
99
  @wbuf = Bytes.empty_byte_buffer
100
100
  end
101
101
 
102
+ def to_s
103
+ "framed(#{@transport.to_s})"
104
+ end
105
+
102
106
  private
103
107
 
104
108
  def read_frame
@@ -113,5 +117,9 @@ module Thrift
113
117
  def get_transport(transport)
114
118
  return FramedTransport.new(transport)
115
119
  end
120
+
121
+ def to_s
122
+ "framed"
123
+ end
116
124
  end
117
- end
125
+ end
@@ -47,11 +47,17 @@ module Thrift
47
47
  http.use_ssl = @url.scheme == 'https'
48
48
  http.verify_mode = @ssl_verify_mode if @url.scheme == 'https'
49
49
  resp = http.post(@url.request_uri, @outbuf, @headers)
50
+ raise TransportException.new(TransportException::UNKNOWN, "#{self.class.name} Could not connect to #{@url}, HTTP status code #{resp.code.to_i}") unless (200..299).include?(resp.code.to_i)
51
+
50
52
  data = resp.body
51
53
  data = Bytes.force_binary_encoding(data)
52
54
  @inbuf = StringIO.new data
53
55
  ensure
54
56
  @outbuf = Bytes.empty_byte_buffer
55
57
  end
58
+
59
+ def to_s
60
+ "@{self.url}"
61
+ end
56
62
  end
57
63
  end
@@ -35,5 +35,8 @@ module Thrift
35
35
  def write(buf); @output.write(Bytes.force_binary_encoding(buf)) end
36
36
  def close; @input.close; @output.close end
37
37
  def to_io; @input end # we're assuming this is used in a IO.select for reading
38
+ def to_s
39
+ "iostream(input=#{@input.to_s},output=#{@output.to_s})"
40
+ end
38
41
  end
39
- end
42
+ end
@@ -121,5 +121,9 @@ module Thrift
121
121
  end
122
122
  out.join(" ")
123
123
  end
124
+
125
+ def to_s
126
+ "memory"
127
+ end
124
128
  end
125
129
  end
@@ -59,5 +59,10 @@ module Thrift
59
59
  end
60
60
 
61
61
  alias to_io handle
62
+
63
+ def to_s
64
+ "socket(#{@host}:#{@port})"
65
+ end
66
+
62
67
  end
63
- end
68
+ end
@@ -134,8 +134,10 @@ module Thrift
134
134
  @handle = nil
135
135
  end
136
136
 
137
- def to_io
138
- @handle
137
+ alias to_io handle
138
+
139
+ def to_s
140
+ "socket(#{@host}:#{@port})"
139
141
  end
140
142
  end
141
143
  end
@@ -33,5 +33,9 @@ module Thrift
33
33
  socket = TCPServer.new(@host, @port)
34
34
  @handle = OpenSSL::SSL::SSLServer.new(socket, @ssl_context)
35
35
  end
36
+
37
+ def to_s
38
+ "ssl(#{super.to_s})"
39
+ end
36
40
  end
37
41
  end
@@ -43,5 +43,9 @@ module Thrift
43
43
  raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
44
44
  end
45
45
  end
46
+
47
+ def to_s
48
+ "ssl(#{super.to_s})"
49
+ end
46
50
  end
47
51
  end
@@ -56,5 +56,9 @@ module Thrift
56
56
  end
57
57
 
58
58
  alias to_io handle
59
+
60
+ def to_s
61
+ "domain(#{@path})"
62
+ end
59
63
  end
60
- end
64
+ end
@@ -36,5 +36,9 @@ module Thrift
36
36
  raise TransportException.new(TransportException::NOT_OPEN, "Could not open UNIX socket at #{@path}")
37
37
  end
38
38
  end
39
+
40
+ def to_s
41
+ "domain(#{@path})"
42
+ end
39
43
  end
40
- end
44
+ end