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.
- checksums.yaml +5 -5
- data/ext/binary_protocol_accelerated.c +5 -5
- data/ext/compact_protocol.c +10 -9
- data/ext/memory_buffer.c +1 -1
- data/ext/struct.c +10 -1
- data/ext/thrift_native.c +17 -0
- data/lib/thrift/client.rb +10 -2
- data/lib/thrift/protocol/base_protocol.rb +11 -3
- data/lib/thrift/protocol/binary_protocol.rb +8 -1
- data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
- data/lib/thrift/protocol/compact_protocol.rb +8 -0
- data/lib/thrift/protocol/json_protocol.rb +8 -0
- data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
- data/lib/thrift/server/base_server.rb +8 -2
- data/lib/thrift/server/simple_server.rb +5 -1
- data/lib/thrift/server/thread_pool_server.rb +5 -1
- data/lib/thrift/server/threaded_server.rb +5 -1
- data/lib/thrift/transport/base_server_transport.rb +1 -1
- data/lib/thrift/transport/base_transport.rb +8 -0
- data/lib/thrift/transport/buffered_transport.rb +9 -1
- data/lib/thrift/transport/framed_transport.rb +9 -1
- data/lib/thrift/transport/http_client_transport.rb +6 -0
- data/lib/thrift/transport/io_stream_transport.rb +4 -1
- data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
- data/lib/thrift/transport/server_socket.rb +6 -1
- data/lib/thrift/transport/socket.rb +4 -2
- data/lib/thrift/transport/ssl_server_socket.rb +4 -0
- data/lib/thrift/transport/ssl_socket.rb +4 -0
- data/lib/thrift/transport/unix_server_socket.rb +5 -1
- data/lib/thrift/transport/unix_socket.rb +5 -1
- data/spec/base_protocol_spec.rb +79 -71
- data/spec/base_transport_spec.rb +155 -117
- data/spec/binary_protocol_accelerated_spec.rb +6 -2
- data/spec/binary_protocol_spec.rb +16 -8
- data/spec/binary_protocol_spec_shared.rb +73 -70
- data/spec/bytes_spec.rb +38 -38
- data/spec/client_spec.rb +43 -42
- data/spec/compact_protocol_spec.rb +23 -8
- data/spec/exception_spec.rb +54 -54
- data/spec/flat_spec.rb +5 -5
- data/spec/http_client_spec.rb +64 -38
- data/spec/json_protocol_spec.rb +146 -138
- data/spec/namespaced_spec.rb +5 -5
- data/spec/nonblocking_server_spec.rb +16 -16
- data/spec/processor_spec.rb +26 -26
- data/spec/serializer_spec.rb +20 -20
- data/spec/server_socket_spec.rb +27 -22
- data/spec/server_spec.rb +91 -52
- data/spec/socket_spec.rb +23 -16
- data/spec/socket_spec_shared.rb +31 -31
- data/spec/spec_helper.rb +5 -0
- data/spec/ssl_server_socket_spec.rb +34 -0
- data/spec/ssl_socket_spec.rb +26 -22
- data/spec/struct_nested_containers_spec.rb +24 -24
- data/spec/struct_spec.rb +120 -120
- data/spec/thin_http_server_spec.rb +18 -18
- data/spec/types_spec.rb +56 -53
- data/spec/union_spec.rb +42 -43
- data/spec/unix_socket_spec.rb +43 -34
- metadata +152 -159
- data/benchmark/gen-rb/benchmark_constants.rb +0 -11
- data/benchmark/gen-rb/benchmark_service.rb +0 -80
- data/benchmark/gen-rb/benchmark_types.rb +0 -10
- data/spec/gen-rb/base/base_service.rb +0 -80
- data/spec/gen-rb/base/base_service_constants.rb +0 -11
- data/spec/gen-rb/base/base_service_types.rb +0 -26
- data/spec/gen-rb/extended/extended_service.rb +0 -78
- data/spec/gen-rb/extended/extended_service_constants.rb +0 -11
- data/spec/gen-rb/extended/extended_service_types.rb +0 -12
- data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +0 -272
- data/spec/gen-rb/flat/referenced_constants.rb +0 -11
- data/spec/gen-rb/flat/referenced_types.rb +0 -17
- data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +0 -11
- data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +0 -28
- data/spec/gen-rb/namespaced_spec_namespace/namespaced_nonblocking_service.rb +0 -272
- data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +0 -11
- data/spec/gen-rb/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +0 -28
- data/spec/gen-rb/nonblocking_service.rb +0 -272
- data/spec/gen-rb/other_namespace/referenced_constants.rb +0 -11
- data/spec/gen-rb/other_namespace/referenced_types.rb +0 -17
- data/spec/gen-rb/thrift_spec_constants.rb +0 -11
- data/spec/gen-rb/thrift_spec_types.rb +0 -538
- data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +0 -278
- data/test/debug_proto/gen-rb/debug_proto_test_types.rb +0 -781
- data/test/debug_proto/gen-rb/empty_service.rb +0 -28
- data/test/debug_proto/gen-rb/inherited.rb +0 -83
- data/test/debug_proto/gen-rb/reverse_order_service.rb +0 -86
- data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +0 -85
- data/test/debug_proto/gen-rb/srv.rb +0 -395
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fe32174805f7e6b9801ebf00500fad76c1922c3f5e816fba597dfc0aae195c5d
|
4
|
+
data.tar.gz: b908a7a66b4bff7fc95728778240d2583d685f2fdcdf563edb125dc571cb0040
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/ext/compact_protocol.c
CHANGED
@@ -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
|
-
|
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
|
53
|
+
def receive_message_begin()
|
54
54
|
fname, mtype, rseqid = @iprot.read_message_begin
|
55
|
-
|
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
|
@@ -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
|
@@ -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
|
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
|
@@ -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
|