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.
Files changed (168) hide show
  1. checksums.yaml +4 -4
  2. data/benchmark/benchmark_constants.rb +11 -0
  3. data/benchmark/benchmark_service.rb +152 -0
  4. data/benchmark/benchmark_types.rb +10 -0
  5. data/ext/struct.c +5 -1
  6. data/lib/thrift/base_stream.rb +85 -0
  7. data/lib/thrift/bidi_stream.rb +183 -0
  8. data/lib/thrift/client.rb +84 -17
  9. data/lib/thrift/definition.rb +4 -0
  10. data/lib/thrift/inbound_stream.rb +72 -0
  11. data/lib/thrift/middleware.rb +42 -0
  12. data/lib/thrift/outbound_stream.rb +52 -0
  13. data/lib/thrift/processor.rb +287 -47
  14. data/lib/thrift/protocol/base_protocol.rb +35 -33
  15. data/lib/thrift/protocol/binary_protocol.rb +8 -1
  16. data/lib/thrift/protocol/binary_protocol_accelerated.rb +8 -0
  17. data/lib/thrift/protocol/compact_protocol.rb +8 -0
  18. data/lib/thrift/protocol/json_protocol.rb +21 -4
  19. data/lib/thrift/protocol/multiplexed_protocol.rb +5 -1
  20. data/lib/thrift/server/base_server.rb +8 -2
  21. data/lib/thrift/server/nonblocking_server.rb +5 -4
  22. data/lib/thrift/server/simple_server.rb +5 -1
  23. data/lib/thrift/server/thread_pool_server.rb +5 -1
  24. data/lib/thrift/server/threaded_server.rb +5 -1
  25. data/lib/thrift/transport/base_server_transport.rb +1 -1
  26. data/lib/thrift/transport/base_transport.rb +8 -0
  27. data/lib/thrift/transport/buffered_transport.rb +9 -1
  28. data/lib/thrift/transport/framed_transport.rb +9 -1
  29. data/lib/thrift/transport/http_client_transport.rb +4 -0
  30. data/lib/thrift/transport/io_stream_transport.rb +4 -1
  31. data/lib/thrift/transport/memory_buffer_transport.rb +4 -0
  32. data/lib/thrift/transport/server_socket.rb +5 -0
  33. data/lib/thrift/transport/socket.rb +21 -17
  34. data/lib/thrift/transport/ssl_server_socket.rb +41 -0
  35. data/lib/thrift/transport/ssl_socket.rb +51 -0
  36. data/lib/thrift/transport/unix_server_socket.rb +5 -1
  37. data/lib/thrift/transport/unix_socket.rb +5 -1
  38. data/lib/thrift/types/annotation/deprecation/deprecation_constants.rb +1 -1
  39. data/lib/thrift/types/annotation/deprecation/deprecation_types.rb +2 -2
  40. data/lib/thrift/types/annotation/exception/exception_constants.rb +17 -0
  41. data/lib/thrift/types/annotation/exception/exception_types.rb +44 -0
  42. data/lib/thrift/types/annotation/naming/naming_constants.rb +1 -1
  43. data/lib/thrift/types/annotation/naming/naming_types.rb +2 -2
  44. data/lib/thrift/types/annotation/rpc/rpc_constants.rb +17 -0
  45. data/lib/thrift/types/annotation/rpc/rpc_types.rb +74 -0
  46. data/lib/thrift/types/annotation_definition/annotation_definition_constants.rb +15 -0
  47. data/lib/thrift/types/annotation_definition/annotation_definition_types.rb +116 -0
  48. data/lib/thrift/types/constant_definition/constant_definition_constants.rb +15 -0
  49. data/lib/thrift/types/constant_definition/constant_definition_types.rb +292 -0
  50. data/lib/thrift/types/core/core_constants.rb +15 -0
  51. data/lib/thrift/types/core/core_types.rb +58 -0
  52. data/lib/thrift/types/enum_definition/enum_definition_constants.rb +15 -0
  53. data/lib/thrift/types/enum_definition/enum_definition_types.rb +106 -0
  54. data/lib/thrift/types/known/any/any_constants.rb +1 -1
  55. data/lib/thrift/types/known/any/any_types.rb +2 -2
  56. data/lib/thrift/types/known/duration/duration_constants.rb +1 -1
  57. data/lib/thrift/types/known/duration/duration_types.rb +2 -2
  58. data/lib/thrift/types/known/timestamp/timestamp_constants.rb +1 -1
  59. data/lib/thrift/types/known/timestamp/timestamp_types.rb +2 -2
  60. data/lib/thrift/types/plugin/plugin.rb +139 -0
  61. data/lib/thrift/types/plugin/plugin_constants.rb +15 -0
  62. data/lib/thrift/types/plugin/plugin_types.rb +106 -0
  63. data/lib/thrift/types/program_definition/program_definition_constants.rb +15 -0
  64. data/lib/thrift/types/program_definition/program_definition_types.rb +137 -0
  65. data/lib/thrift/types/service_definition/service_definition_constants.rb +15 -0
  66. data/lib/thrift/types/service_definition/service_definition_types.rb +160 -0
  67. data/lib/thrift/types/struct_definition/struct_definition_constants.rb +15 -0
  68. data/lib/thrift/types/struct_definition/struct_definition_types.rb +157 -0
  69. data/lib/thrift/types/type_definition/type_definition_constants.rb +15 -0
  70. data/lib/thrift/types/type_definition/type_definition_types.rb +242 -0
  71. data/lib/thrift/types/value/value_constants.rb +1 -1
  72. data/lib/thrift/types/value/value_types.rb +50 -51
  73. data/lib/thrift/types.rb +11 -3
  74. data/lib/thrift/union.rb +3 -6
  75. data/lib/thrift.rb +6 -0
  76. data/lib/types/annotation/deprecation/deprecation_constants.rb +16 -0
  77. data/lib/types/annotation/deprecation/deprecation_types.rb +42 -0
  78. data/lib/types/annotation/naming/naming_constants.rb +16 -0
  79. data/lib/types/annotation/naming/naming_types.rb +57 -0
  80. data/lib/types/annotation_definition/annotation_definition_constants.rb +14 -0
  81. data/lib/types/annotation_definition/annotation_definition_types.rb +114 -0
  82. data/lib/types/constant_definition/constant_definition_constants.rb +14 -0
  83. data/lib/types/constant_definition/constant_definition_types.rb +290 -0
  84. data/lib/types/core/core_constants.rb +14 -0
  85. data/lib/types/core/core_types.rb +56 -0
  86. data/lib/types/enum_definition/enum_definition_constants.rb +14 -0
  87. data/lib/types/enum_definition/enum_definition_types.rb +104 -0
  88. data/lib/types/known/any/any_constants.rb +16 -0
  89. data/lib/types/known/any/any_types.rb +59 -0
  90. data/lib/types/known/duration/duration_constants.rb +16 -0
  91. data/lib/types/known/duration/duration_types.rb +59 -0
  92. data/lib/types/known/timestamp/timestamp_constants.rb +16 -0
  93. data/lib/types/known/timestamp/timestamp_types.rb +59 -0
  94. data/lib/types/plugin/plugin.rb +137 -0
  95. data/lib/types/plugin/plugin_constants.rb +14 -0
  96. data/lib/types/plugin/plugin_types.rb +104 -0
  97. data/lib/types/program_definition/program_definition_constants.rb +14 -0
  98. data/lib/types/program_definition/program_definition_types.rb +135 -0
  99. data/lib/types/service_definition/service_definition_constants.rb +14 -0
  100. data/lib/types/service_definition/service_definition_types.rb +158 -0
  101. data/lib/types/struct_definition/struct_definition_constants.rb +14 -0
  102. data/lib/types/struct_definition/struct_definition_types.rb +155 -0
  103. data/lib/types/type_definition/type_definition_constants.rb +14 -0
  104. data/lib/types/type_definition/type_definition_types.rb +240 -0
  105. data/lib/types/value/value_constants.rb +14 -0
  106. data/lib/types/value/value_types.rb +330 -0
  107. data/spec/base/base_service.rb +152 -0
  108. data/spec/base/base_service_constants.rb +11 -0
  109. data/spec/base/base_service_types.rb +45 -0
  110. data/spec/base_protocol_spec.rb +79 -71
  111. data/spec/base_transport_spec.rb +155 -117
  112. data/spec/binary_protocol_accelerated_spec.rb +6 -2
  113. data/spec/binary_protocol_spec.rb +16 -8
  114. data/spec/binary_protocol_spec_shared.rb +77 -77
  115. data/spec/bytes_spec.rb +38 -38
  116. data/spec/client_spec.rb +48 -50
  117. data/spec/compact_protocol_spec.rb +59 -46
  118. data/spec/exception_spec.rb +54 -54
  119. data/spec/extended/extended_service.rb +137 -0
  120. data/spec/extended/extended_service_constants.rb +11 -0
  121. data/spec/extended/extended_service_types.rb +12 -0
  122. data/spec/flat_spec.rb +5 -5
  123. data/spec/gen-rb/flat/namespaced_nonblocking_service.rb +507 -0
  124. data/spec/gen-rb/flat/referenced_constants.rb +11 -0
  125. data/spec/gen-rb/flat/referenced_types.rb +17 -0
  126. data/spec/gen-rb/flat/thrift_namespaced_spec_constants.rb +11 -0
  127. data/spec/gen-rb/flat/thrift_namespaced_spec_types.rb +47 -0
  128. data/spec/http_client_spec.rb +96 -43
  129. data/spec/json_protocol_spec.rb +170 -131
  130. data/spec/namespaced_spec.rb +24 -27
  131. data/spec/namespaced_spec_namespace/namespaced_nonblocking_service.rb +507 -0
  132. data/spec/namespaced_spec_namespace/thrift_namespaced_spec_constants.rb +11 -0
  133. data/spec/namespaced_spec_namespace/thrift_namespaced_spec_types.rb +47 -0
  134. data/spec/nonblocking_server_spec.rb +16 -16
  135. data/spec/nonblocking_service.rb +507 -0
  136. data/spec/other_namespace/referenced_constants.rb +11 -0
  137. data/spec/other_namespace/referenced_types.rb +17 -0
  138. data/spec/processor_spec.rb +42 -31
  139. data/spec/rack_application_spec.rb +22 -26
  140. data/spec/serializer_spec.rb +20 -20
  141. data/spec/server_socket_spec.rb +27 -22
  142. data/spec/server_spec.rb +91 -51
  143. data/spec/socket_spec.rb +23 -16
  144. data/spec/socket_spec_shared.rb +31 -31
  145. data/spec/spec_helper.rb +17 -17
  146. data/spec/ssl_server_socket_spec.rb +34 -0
  147. data/spec/ssl_socket_spec.rb +78 -0
  148. data/spec/streaming_spec.rb +442 -0
  149. data/spec/struct_nested_containers_spec.rb +24 -24
  150. data/spec/struct_spec.rb +120 -120
  151. data/spec/thin_http_server_spec.rb +71 -28
  152. data/spec/thrift_spec_constants.rb +11 -0
  153. data/spec/thrift_spec_types.rb +1173 -0
  154. data/spec/types/known/any_spec.rb +2 -2
  155. data/spec/types/known/duration_spec.rb +1 -1
  156. data/spec/types/known/timestamp_spec.rb +1 -1
  157. data/spec/types/value_spec.rb +2 -1
  158. data/spec/types_spec.rb +56 -53
  159. data/spec/union_spec.rb +51 -40
  160. data/spec/unix_socket_spec.rb +43 -34
  161. data/test/debug_proto/gen-rb/debug_proto_test_constants.rb +281 -0
  162. data/test/debug_proto/gen-rb/debug_proto_test_types.rb +2033 -0
  163. data/test/debug_proto/gen-rb/empty_service.rb +52 -0
  164. data/test/debug_proto/gen-rb/inherited.rb +155 -0
  165. data/test/debug_proto/gen-rb/reverse_order_service.rb +169 -0
  166. data/test/debug_proto/gen-rb/service_for_exception_with_a_map.rb +150 -0
  167. data/test/debug_proto/gen-rb/srv.rb +718 -0
  168. 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
@@ -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,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
@@ -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
@@ -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([@server_transport], nil, nil, 0.1)
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
@@ -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
@@ -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
@@ -63,6 +63,10 @@ module Thrift
63
63
  @outbuf = Bytes.empty_byte_buffer
64
64
  end
65
65
 
66
+ def to_s
67
+ "@{self.url}"
68
+ end
69
+
66
70
  private
67
71
 
68
72
  def http_client
@@ -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
68
  end
@@ -33,26 +33,28 @@ module Thrift
33
33
  attr_accessor :handle, :timeout
34
34
 
35
35
  def open
36
- begin
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
- @handle.connect_nonblock(sockaddr)
43
- rescue Errno::EINPROGRESS
44
- unless IO.select(nil, [ @handle ], nil, @timeout)
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
- @handle.connect_nonblock(sockaddr)
49
- rescue Errno::EISCONN
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
- def to_io
136
- @handle
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (2.5.4-upfluence)
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
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (2.5.4-upfluence)
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.5.4-upfluence)
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
  #
@@ -1,5 +1,5 @@
1
1
  #
2
- # Autogenerated by Thrift Compiler (2.5.4-upfluence)
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