upfluence-thrift 2.6.1 → 2.7.4
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 +4 -4
- data/benchmark/benchmark_constants.rb +11 -0
- data/benchmark/benchmark_service.rb +152 -0
- data/benchmark/benchmark_types.rb +10 -0
- data/ext/struct.c +5 -1
- data/lib/thrift/base_stream.rb +85 -0
- data/lib/thrift/bidi_stream.rb +183 -0
- data/lib/thrift/client.rb +84 -17
- data/lib/thrift/definition.rb +4 -0
- data/lib/thrift/inbound_stream.rb +72 -0
- data/lib/thrift/middleware.rb +42 -0
- data/lib/thrift/outbound_stream.rb +52 -0
- data/lib/thrift/processor.rb +287 -47
- data/lib/thrift/protocol/base_protocol.rb +35 -33
- 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 +21 -4
- data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
- data/lib/thrift/server/base_server.rb +8 -2
- data/lib/thrift/server/nonblocking_server.rb +5 -4
- 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 +4 -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 +5 -0
- data/lib/thrift/transport/socket.rb +21 -17
- data/lib/thrift/transport/ssl_server_socket.rb +41 -0
- data/lib/thrift/transport/ssl_socket.rb +51 -0
- data/lib/thrift/transport/unix_server_socket.rb +5 -1
- data/lib/thrift/transport/unix_socket.rb +5 -1
- data/lib/thrift/types/annotation/deprecation/deprecation_constants.rb +1 -1
- data/lib/thrift/types/annotation/deprecation/deprecation_types.rb +2 -2
- data/lib/thrift/types/annotation/exception/exception_constants.rb +17 -0
- data/lib/thrift/types/annotation/exception/exception_types.rb +44 -0
- data/lib/thrift/types/annotation/naming/naming_constants.rb +1 -1
- data/lib/thrift/types/annotation/naming/naming_types.rb +2 -2
- data/lib/thrift/types/annotation/rpc/rpc_constants.rb +17 -0
- data/lib/thrift/types/annotation/rpc/rpc_types.rb +74 -0
- data/lib/thrift/types/annotation_definition/annotation_definition_constants.rb +15 -0
- data/lib/thrift/types/annotation_definition/annotation_definition_types.rb +116 -0
- data/lib/thrift/types/constant_definition/constant_definition_constants.rb +15 -0
- data/lib/thrift/types/constant_definition/constant_definition_types.rb +292 -0
- data/lib/thrift/types/core/core_constants.rb +15 -0
- data/lib/thrift/types/core/core_types.rb +58 -0
- data/lib/thrift/types/enum_definition/enum_definition_constants.rb +15 -0
- data/lib/thrift/types/enum_definition/enum_definition_types.rb +106 -0
- data/lib/thrift/types/known/any/any_constants.rb +1 -1
- data/lib/thrift/types/known/any/any_types.rb +2 -2
- data/lib/thrift/types/known/duration/duration_constants.rb +1 -1
- data/lib/thrift/types/known/duration/duration_types.rb +2 -2
- data/lib/thrift/types/known/timestamp/timestamp_constants.rb +1 -1
- data/lib/thrift/types/known/timestamp/timestamp_types.rb +2 -2
- data/lib/thrift/types/plugin/plugin.rb +139 -0
- data/lib/thrift/types/plugin/plugin_constants.rb +15 -0
- data/lib/thrift/types/plugin/plugin_types.rb +106 -0
- data/lib/thrift/types/program_definition/program_definition_constants.rb +15 -0
- data/lib/thrift/types/program_definition/program_definition_types.rb +137 -0
- data/lib/thrift/types/service_definition/service_definition_constants.rb +15 -0
- data/lib/thrift/types/service_definition/service_definition_types.rb +160 -0
- data/lib/thrift/types/struct_definition/struct_definition_constants.rb +15 -0
- data/lib/thrift/types/struct_definition/struct_definition_types.rb +157 -0
- data/lib/thrift/types/type_definition/type_definition_constants.rb +15 -0
- data/lib/thrift/types/type_definition/type_definition_types.rb +242 -0
- data/lib/thrift/types/value/value_constants.rb +1 -1
- data/lib/thrift/types/value/value_types.rb +50 -51
- data/lib/thrift/types.rb +11 -3
- data/lib/thrift/union.rb +3 -6
- data/lib/thrift.rb +6 -0
- data/lib/types/annotation/deprecation/deprecation_constants.rb +16 -0
- data/lib/types/annotation/deprecation/deprecation_types.rb +42 -0
- data/lib/types/annotation/naming/naming_constants.rb +16 -0
- data/lib/types/annotation/naming/naming_types.rb +57 -0
- data/lib/types/annotation_definition/annotation_definition_constants.rb +14 -0
- data/lib/types/annotation_definition/annotation_definition_types.rb +114 -0
- data/lib/types/constant_definition/constant_definition_constants.rb +14 -0
- data/lib/types/constant_definition/constant_definition_types.rb +290 -0
- data/lib/types/core/core_constants.rb +14 -0
- data/lib/types/core/core_types.rb +56 -0
- data/lib/types/enum_definition/enum_definition_constants.rb +14 -0
- data/lib/types/enum_definition/enum_definition_types.rb +104 -0
- data/lib/types/known/any/any_constants.rb +16 -0
- data/lib/types/known/any/any_types.rb +59 -0
- data/lib/types/known/duration/duration_constants.rb +16 -0
- data/lib/types/known/duration/duration_types.rb +59 -0
- data/lib/types/known/timestamp/timestamp_constants.rb +16 -0
- data/lib/types/known/timestamp/timestamp_types.rb +59 -0
- data/lib/types/plugin/plugin.rb +137 -0
- data/lib/types/plugin/plugin_constants.rb +14 -0
- data/lib/types/plugin/plugin_types.rb +104 -0
- data/lib/types/program_definition/program_definition_constants.rb +14 -0
- data/lib/types/program_definition/program_definition_types.rb +135 -0
- data/lib/types/service_definition/service_definition_constants.rb +14 -0
- data/lib/types/service_definition/service_definition_types.rb +158 -0
- data/lib/types/struct_definition/struct_definition_constants.rb +14 -0
- data/lib/types/struct_definition/struct_definition_types.rb +155 -0
- data/lib/types/type_definition/type_definition_constants.rb +14 -0
- data/lib/types/type_definition/type_definition_types.rb +240 -0
- data/lib/types/value/value_constants.rb +14 -0
- data/lib/types/value/value_types.rb +330 -0
- data/spec/base/base_service.rb +152 -0
- data/spec/base/base_service_constants.rb +11 -0
- data/spec/base/base_service_types.rb +45 -0
- 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 +77 -77
- data/spec/bytes_spec.rb +38 -38
- data/spec/client_spec.rb +48 -50
- data/spec/compact_protocol_spec.rb +59 -46
- data/spec/exception_spec.rb +54 -54
- data/spec/extended/extended_service.rb +137 -0
- data/spec/extended/extended_service_constants.rb +11 -0
- data/spec/extended/extended_service_types.rb +12 -0
- data/spec/flat_spec.rb +5 -5
- data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +507 -0
- data/spec/gen-rb/flat/referenced_constants.rb +11 -0
- data/spec/gen-rb/flat/referenced_types.rb +17 -0
- data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +11 -0
- data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +47 -0
- data/spec/http_client_spec.rb +96 -43
- data/spec/json_protocol_spec.rb +170 -131
- data/spec/namespaced_spec.rb +24 -27
- data/spec/namespaced_spec_namespace/namespaced_nonblocking_service.rb +507 -0
- data/spec/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +11 -0
- data/spec/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +47 -0
- data/spec/nonblocking_server_spec.rb +16 -16
- data/spec/nonblocking_service.rb +507 -0
- data/spec/other_namespace/referenced_constants.rb +11 -0
- data/spec/other_namespace/referenced_types.rb +17 -0
- data/spec/processor_spec.rb +42 -31
- data/spec/rack_application_spec.rb +22 -26
- data/spec/serializer_spec.rb +20 -20
- data/spec/server_socket_spec.rb +27 -22
- data/spec/server_spec.rb +91 -51
- data/spec/socket_spec.rb +23 -16
- data/spec/socket_spec_shared.rb +31 -31
- data/spec/spec_helper.rb +17 -17
- data/spec/ssl_server_socket_spec.rb +34 -0
- data/spec/ssl_socket_spec.rb +78 -0
- data/spec/streaming_spec.rb +442 -0
- data/spec/struct_nested_containers_spec.rb +24 -24
- data/spec/struct_spec.rb +120 -120
- data/spec/thin_http_server_spec.rb +71 -28
- data/spec/thrift_spec_constants.rb +11 -0
- data/spec/thrift_spec_types.rb +1173 -0
- data/spec/types/known/any_spec.rb +2 -2
- data/spec/types/known/duration_spec.rb +1 -1
- data/spec/types/known/timestamp_spec.rb +1 -1
- data/spec/types/value_spec.rb +2 -1
- data/spec/types_spec.rb +56 -53
- data/spec/union_spec.rb +51 -40
- data/spec/unix_socket_spec.rb +43 -34
- data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +281 -0
- data/test/debug_proto/gen-rb/debug_proto_test_types.rb +2033 -0
- data/test/debug_proto/gen-rb/empty_service.rb +52 -0
- data/test/debug_proto/gen-rb/inherited.rb +155 -0
- data/test/debug_proto/gen-rb/reverse_order_service.rb +169 -0
- data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +150 -0
- data/test/debug_proto/gen-rb/srv.rb +718 -0
- metadata +202 -7
|
@@ -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
|
|
@@ -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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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,6 +768,10 @@ 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 SimpleJsonProtocol < JsonProtocol
|
|
@@ -829,5 +842,9 @@ module Thrift
|
|
|
829
842
|
def get_protocol(trans)
|
|
830
843
|
Thrift::JsonProtocol.new(trans)
|
|
831
844
|
end
|
|
845
|
+
|
|
846
|
+
def to_s
|
|
847
|
+
"json"
|
|
848
|
+
end
|
|
832
849
|
end
|
|
833
850
|
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
|
|
@@ -44,14 +44,15 @@ module Thrift
|
|
|
44
44
|
begin
|
|
45
45
|
loop do
|
|
46
46
|
break if @server_transport.closed?
|
|
47
|
+
handle = @server_transport.handle
|
|
48
|
+
break if handle.nil?
|
|
47
49
|
begin
|
|
48
|
-
rd, = select([
|
|
49
|
-
rescue Errno::EBADF => e
|
|
50
|
-
# In Ruby 1.9, calling @server_transport.close in shutdown paths causes the select() to raise an
|
|
51
|
-
# Errno::EBADF. If this happens, ignore it and retry the loop.
|
|
50
|
+
rd, = IO.select([handle], nil, nil, 0.1)
|
|
51
|
+
rescue Errno::EBADF, IOError => e
|
|
52
52
|
break
|
|
53
53
|
end
|
|
54
54
|
next if rd.nil?
|
|
55
|
+
break if @server_transport.closed?
|
|
55
56
|
socket = @server_transport.accept
|
|
56
57
|
@logger.debug "Accepted socket: #{socket.inspect}"
|
|
57
58
|
@io_manager.add_connection socket
|
|
@@ -101,11 +101,19 @@ module Thrift
|
|
|
101
101
|
alias_method :<<, :write
|
|
102
102
|
|
|
103
103
|
def flush; end
|
|
104
|
+
|
|
105
|
+
def to_s
|
|
106
|
+
"base"
|
|
107
|
+
end
|
|
104
108
|
end
|
|
105
109
|
|
|
106
110
|
class BaseTransportFactory
|
|
107
111
|
def get_transport(trans)
|
|
108
112
|
return trans
|
|
109
113
|
end
|
|
114
|
+
|
|
115
|
+
def to_s
|
|
116
|
+
"base"
|
|
117
|
+
end
|
|
110
118
|
end
|
|
111
119
|
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
|
|
@@ -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
|
|
@@ -33,26 +33,28 @@ module Thrift
|
|
|
33
33
|
attr_accessor :handle, :timeout
|
|
34
34
|
|
|
35
35
|
def open
|
|
36
|
-
|
|
37
|
-
addrinfo = ::Socket::getaddrinfo(@host, @port, nil, ::Socket::SOCK_STREAM).first
|
|
38
|
-
@handle = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0)
|
|
39
|
-
@handle.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
|
|
40
|
-
sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3])
|
|
36
|
+
for addrinfo in ::Socket::getaddrinfo(@host, @port, nil, ::Socket::SOCK_STREAM) do
|
|
41
37
|
begin
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
raise TransportException.new(TransportException::NOT_OPEN, "Connection timeout to #{@desc}")
|
|
46
|
-
end
|
|
38
|
+
socket = ::Socket.new(addrinfo[4], ::Socket::SOCK_STREAM, 0)
|
|
39
|
+
socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
|
|
40
|
+
sockaddr = ::Socket.sockaddr_in(addrinfo[1], addrinfo[3])
|
|
47
41
|
begin
|
|
48
|
-
|
|
49
|
-
rescue Errno::
|
|
42
|
+
socket.connect_nonblock(sockaddr)
|
|
43
|
+
rescue Errno::EINPROGRESS
|
|
44
|
+
unless IO.select(nil, [ socket ], nil, @timeout)
|
|
45
|
+
next
|
|
46
|
+
end
|
|
47
|
+
begin
|
|
48
|
+
socket.connect_nonblock(sockaddr)
|
|
49
|
+
rescue Errno::EISCONN
|
|
50
|
+
end
|
|
50
51
|
end
|
|
52
|
+
return @handle = socket
|
|
53
|
+
rescue StandardError => e
|
|
54
|
+
next
|
|
51
55
|
end
|
|
52
|
-
@handle
|
|
53
|
-
rescue StandardError => e
|
|
54
|
-
raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
|
|
55
56
|
end
|
|
57
|
+
raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
|
|
56
58
|
end
|
|
57
59
|
|
|
58
60
|
def open?
|
|
@@ -132,8 +134,10 @@ module Thrift
|
|
|
132
134
|
@handle = nil
|
|
133
135
|
end
|
|
134
136
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
+
alias to_io handle
|
|
138
|
+
|
|
139
|
+
def to_s
|
|
140
|
+
"socket(#{@host}:#{@port})"
|
|
137
141
|
end
|
|
138
142
|
end
|
|
139
143
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
#
|
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'socket'
|
|
22
|
+
|
|
23
|
+
module Thrift
|
|
24
|
+
class SSLServerSocket < ServerSocket
|
|
25
|
+
def initialize(host_or_port, port = nil, ssl_context = nil)
|
|
26
|
+
super(host_or_port, port)
|
|
27
|
+
@ssl_context = ssl_context
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
attr_accessor :ssl_context
|
|
31
|
+
|
|
32
|
+
def listen
|
|
33
|
+
socket = TCPServer.new(@host, @port)
|
|
34
|
+
@handle = OpenSSL::SSL::SSLServer.new(socket, @ssl_context)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_s
|
|
38
|
+
"ssl(#{super.to_s})"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# encoding: ascii-8bit
|
|
2
|
+
#
|
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
|
|
20
|
+
module Thrift
|
|
21
|
+
class SSLSocket < Socket
|
|
22
|
+
def initialize(host='localhost', port=9090, timeout=nil, ssl_context=nil)
|
|
23
|
+
super(host, port, timeout)
|
|
24
|
+
@ssl_context = ssl_context
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
attr_accessor :ssl_context
|
|
28
|
+
|
|
29
|
+
def open
|
|
30
|
+
socket = super
|
|
31
|
+
@handle = OpenSSL::SSL::SSLSocket.new(socket, @ssl_context)
|
|
32
|
+
begin
|
|
33
|
+
@handle.connect_nonblock
|
|
34
|
+
@handle.post_connection_check(@host)
|
|
35
|
+
@handle
|
|
36
|
+
rescue IO::WaitReadable
|
|
37
|
+
IO.select([ @handle ], nil, nil, @timeout)
|
|
38
|
+
retry
|
|
39
|
+
rescue IO::WaitWritable
|
|
40
|
+
IO.select(nil, [ @handle ], nil, @timeout)
|
|
41
|
+
retry
|
|
42
|
+
rescue StandardError => e
|
|
43
|
+
raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def to_s
|
|
48
|
+
"ssl(#{super.to_s})"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Autogenerated by Thrift Compiler (2.
|
|
2
|
+
# Autogenerated by Thrift Compiler (2.7.0-upfluence)
|
|
3
3
|
#
|
|
4
4
|
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
5
|
#
|
|
@@ -27,7 +27,7 @@ module Thrift
|
|
|
27
27
|
|
|
28
28
|
FIELDS = {
|
|
29
29
|
|
|
30
|
-
}
|
|
30
|
+
}.freeze
|
|
31
31
|
|
|
32
32
|
def struct_fields; FIELDS; end
|
|
33
33
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Autogenerated by Thrift Compiler (2.7.0-upfluence)
|
|
3
|
+
#
|
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'thrift'
|
|
8
|
+
require 'thrift/types/annotation/exception/exception_types'
|
|
9
|
+
|
|
10
|
+
module Thrift
|
|
11
|
+
module Types
|
|
12
|
+
module Annotation
|
|
13
|
+
module Exception
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Autogenerated by Thrift Compiler (2.7.0-upfluence)
|
|
3
|
+
#
|
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'thrift'
|
|
8
|
+
|
|
9
|
+
module Thrift
|
|
10
|
+
module Types
|
|
11
|
+
module Annotation
|
|
12
|
+
module Exception
|
|
13
|
+
class Safe; end
|
|
14
|
+
|
|
15
|
+
class Safe
|
|
16
|
+
include ::Thrift::Struct, ::Thrift::Struct_Union
|
|
17
|
+
|
|
18
|
+
NAME = 'Safe'.freeze
|
|
19
|
+
NAMESPACE = 'types.annotation.exception'.freeze
|
|
20
|
+
|
|
21
|
+
LEGACY_ANNOTATIONS = {
|
|
22
|
+
}.freeze
|
|
23
|
+
|
|
24
|
+
STRUCTURED_ANNOTATIONS = [
|
|
25
|
+
].freeze
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
FIELDS = {
|
|
29
|
+
|
|
30
|
+
}.freeze
|
|
31
|
+
|
|
32
|
+
def struct_fields; FIELDS; end
|
|
33
|
+
|
|
34
|
+
def validate
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
::Thrift::Struct.generate_accessors self
|
|
38
|
+
::Thrift.register_struct_type self
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Autogenerated by Thrift Compiler (2.
|
|
2
|
+
# Autogenerated by Thrift Compiler (2.7.0-upfluence)
|
|
3
3
|
#
|
|
4
4
|
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
5
|
#
|
|
@@ -42,7 +42,7 @@ module Thrift
|
|
|
42
42
|
FIELDS = {
|
|
43
43
|
THRIFT_FIELD_INDEX_NAMESPACE_ => {type: ::Thrift::Types::STRING, name: 'namespace_', optional: true, legacy_annotations: THRIFT_FIELD_NAMESPACE__LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_NAMESPACE__STRUCTURED_ANNOTATIONS},
|
|
44
44
|
THRIFT_FIELD_INDEX_NAME => {type: ::Thrift::Types::STRING, name: 'name', optional: true, legacy_annotations: THRIFT_FIELD_NAME_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_NAME_STRUCTURED_ANNOTATIONS}
|
|
45
|
-
}
|
|
45
|
+
}.freeze
|
|
46
46
|
|
|
47
47
|
def struct_fields; FIELDS; end
|
|
48
48
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Autogenerated by Thrift Compiler (2.7.0-upfluence)
|
|
3
|
+
#
|
|
4
|
+
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'thrift'
|
|
8
|
+
require 'thrift/types/annotation/rpc/rpc_types'
|
|
9
|
+
|
|
10
|
+
module Thrift
|
|
11
|
+
module Types
|
|
12
|
+
module Annotation
|
|
13
|
+
module Rpc
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|