thrift 0.22.0 → 0.23.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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +175 -17
  3. data/benchmark/benchmark.rb +22 -8
  4. data/benchmark/client.rb +49 -6
  5. data/benchmark/server.rb +45 -7
  6. data/benchmark/thin_server.rb +1 -0
  7. data/ext/binary_protocol_accelerated.c +76 -19
  8. data/ext/compact_protocol.c +80 -15
  9. data/ext/constants.h +12 -0
  10. data/ext/extconf.rb +10 -9
  11. data/ext/memory_buffer.c +7 -7
  12. data/ext/protocol.c +29 -0
  13. data/ext/protocol.h +35 -0
  14. data/ext/struct.c +36 -5
  15. data/ext/thrift_native.c +27 -3
  16. data/lib/thrift/bytes.rb +68 -101
  17. data/lib/thrift/client.rb +61 -9
  18. data/lib/thrift/exceptions.rb +5 -5
  19. data/lib/thrift/multiplexed_processor.rb +6 -6
  20. data/lib/thrift/processor.rb +6 -6
  21. data/lib/thrift/protocol/base_protocol.rb +37 -15
  22. data/lib/thrift/protocol/binary_protocol.rb +25 -9
  23. data/lib/thrift/protocol/binary_protocol_accelerated.rb +5 -5
  24. data/lib/thrift/protocol/compact_protocol.rb +61 -37
  25. data/lib/thrift/protocol/header_protocol.rb +320 -0
  26. data/lib/thrift/protocol/json_protocol.rb +26 -16
  27. data/lib/thrift/protocol/multiplexed_protocol.rb +5 -5
  28. data/lib/thrift/protocol/protocol_decorator.rb +12 -4
  29. data/lib/thrift/serializer/deserializer.rb +5 -5
  30. data/lib/thrift/serializer/serializer.rb +4 -5
  31. data/lib/thrift/server/base_server.rb +4 -4
  32. data/lib/thrift/server/mongrel_http_server.rb +6 -6
  33. data/lib/thrift/server/nonblocking_server.rb +8 -8
  34. data/lib/thrift/server/simple_server.rb +4 -4
  35. data/lib/thrift/server/thin_http_server.rb +3 -3
  36. data/lib/thrift/server/thread_pool_server.rb +6 -6
  37. data/lib/thrift/server/threaded_server.rb +4 -4
  38. data/lib/thrift/struct.rb +11 -11
  39. data/lib/thrift/struct_union.rb +19 -9
  40. data/lib/thrift/thrift_native.rb +1 -1
  41. data/lib/thrift/transport/base_server_transport.rb +5 -5
  42. data/lib/thrift/transport/base_transport.rb +12 -12
  43. data/lib/thrift/transport/buffered_transport.rb +6 -6
  44. data/lib/thrift/transport/framed_transport.rb +7 -7
  45. data/lib/thrift/transport/header_transport.rb +516 -0
  46. data/lib/thrift/transport/http_client_transport.rb +1 -1
  47. data/lib/thrift/transport/io_stream_transport.rb +3 -3
  48. data/lib/thrift/transport/memory_buffer_transport.rb +6 -6
  49. data/lib/thrift/transport/server_socket.rb +8 -5
  50. data/lib/thrift/transport/socket.rb +58 -31
  51. data/lib/thrift/transport/ssl_server_socket.rb +1 -1
  52. data/lib/thrift/transport/ssl_socket.rb +2 -2
  53. data/lib/thrift/transport/unix_server_socket.rb +4 -4
  54. data/lib/thrift/transport/unix_socket.rb +6 -6
  55. data/lib/thrift/types.rb +9 -6
  56. data/lib/thrift/union.rb +14 -8
  57. data/lib/thrift/uuid.rb +49 -0
  58. data/lib/thrift.rb +3 -1
  59. data/spec/ThriftSpec.thrift +5 -1
  60. data/spec/base_protocol_spec.rb +1 -2
  61. data/spec/base_transport_spec.rb +6 -7
  62. data/spec/binary_protocol_spec.rb +0 -2
  63. data/spec/binary_protocol_spec_shared.rb +129 -142
  64. data/spec/bytes_spec.rb +57 -118
  65. data/spec/client_spec.rb +85 -19
  66. data/spec/compact_protocol_spec.rb +54 -16
  67. data/spec/constants_demo_spec.rb +101 -0
  68. data/spec/exception_spec.rb +0 -1
  69. data/spec/header_protocol_spec.rb +475 -0
  70. data/spec/header_transport_spec.rb +386 -0
  71. data/spec/http_client_spec.rb +4 -6
  72. data/spec/json_protocol_spec.rb +47 -47
  73. data/spec/namespaced_spec.rb +0 -1
  74. data/spec/nonblocking_server_spec.rb +102 -4
  75. data/spec/processor_spec.rb +0 -1
  76. data/spec/serializer_spec.rb +0 -1
  77. data/spec/server_socket_spec.rb +1 -1
  78. data/spec/server_spec.rb +8 -9
  79. data/spec/socket_spec.rb +0 -1
  80. data/spec/socket_spec_shared.rb +72 -9
  81. data/spec/spec_helper.rb +1 -1
  82. data/spec/ssl_server_socket_spec.rb +12 -1
  83. data/spec/ssl_socket_spec.rb +10 -1
  84. data/spec/struct_nested_containers_spec.rb +1 -2
  85. data/spec/struct_spec.rb +113 -9
  86. data/spec/support/header_protocol_helper.rb +54 -0
  87. data/spec/thin_http_server_spec.rb +3 -18
  88. data/spec/types_spec.rb +25 -26
  89. data/spec/union_spec.rb +69 -11
  90. data/spec/unix_socket_spec.rb +1 -2
  91. data/spec/uuid_validation_spec.rb +238 -0
  92. data/test/fuzz/Makefile.am +173 -0
  93. data/test/fuzz/README.md +149 -0
  94. data/test/fuzz/fuzz_common.rb +95 -0
  95. data/{lib/thrift/core_ext.rb → test/fuzz/fuzz_parse_binary_protocol.rb} +3 -4
  96. data/{lib/thrift/core_ext/fixnum.rb → test/fuzz/fuzz_parse_binary_protocol_accelerated.rb} +6 -13
  97. data/test/fuzz/fuzz_parse_binary_protocol_accelerated_harness.rb +22 -0
  98. data/test/fuzz/fuzz_parse_binary_protocol_harness.rb +22 -0
  99. data/test/fuzz/fuzz_parse_compact_protocol.rb +22 -0
  100. data/test/fuzz/fuzz_parse_compact_protocol_harness.rb +22 -0
  101. data/test/fuzz/fuzz_parse_json_protocol.rb +22 -0
  102. data/test/fuzz/fuzz_parse_json_protocol_harness.rb +22 -0
  103. data/test/fuzz/fuzz_roundtrip_binary_protocol.rb +22 -0
  104. data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated.rb +22 -0
  105. data/test/fuzz/fuzz_roundtrip_binary_protocol_accelerated_harness.rb +22 -0
  106. data/test/fuzz/fuzz_roundtrip_binary_protocol_harness.rb +22 -0
  107. data/test/fuzz/fuzz_roundtrip_compact_protocol.rb +22 -0
  108. data/test/fuzz/fuzz_roundtrip_compact_protocol_harness.rb +22 -0
  109. data/test/fuzz/fuzz_roundtrip_json_protocol.rb +22 -0
  110. data/test/fuzz/fuzz_roundtrip_json_protocol_harness.rb +22 -0
  111. data/test/fuzz/fuzz_tracer.rb +28 -0
  112. metadata +106 -37
@@ -1,5 +1,5 @@
1
1
  # encoding: ascii-8bit
2
- #
2
+ #
3
3
  # Licensed to the Apache Software Foundation (ASF) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -7,22 +7,22 @@
7
7
  # to you under the Apache License, Version 2.0 (the
8
8
  # "License"); you may not use this file except in compliance
9
9
  # with the License. You may obtain a copy of the License at
10
- #
10
+ #
11
11
  # http://www.apache.org/licenses/LICENSE-2.0
12
- #
12
+ #
13
13
  # Unless required by applicable law or agreed to in writing,
14
14
  # software distributed under the License is distributed on an
15
15
  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
16
  # KIND, either express or implied. See the License for the
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
- #
19
+ #
20
20
 
21
21
  require 'socket'
22
22
 
23
23
  module Thrift
24
24
  class Socket < BaseTransport
25
- def initialize(host='localhost', port=9090, timeout=nil)
25
+ def initialize(host = 'localhost', port = 9090, timeout = nil)
26
26
  @host = host
27
27
  @port = port
28
28
  @timeout = timeout
@@ -62,26 +62,26 @@ module Thrift
62
62
  end
63
63
 
64
64
  def write(str)
65
- raise IOError, "closed stream" unless open?
65
+ raise TransportException.new(TransportException::NOT_OPEN, "closed stream") unless open?
66
66
  str = Bytes.force_binary_encoding(str)
67
67
  begin
68
68
  if @timeout.nil? or @timeout == 0
69
69
  @handle.write(str)
70
70
  else
71
+ deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + @timeout
71
72
  len = 0
72
- start = Time.now
73
- while Time.now - start < @timeout
74
- rd, wr, = IO.select(nil, [@handle], nil, @timeout)
75
- if wr and not wr.empty?
73
+
74
+ while len < str.length
75
+ begin
76
76
  len += @handle.write_nonblock(str[len..-1])
77
- break if len >= str.length
77
+ rescue IO::WaitWritable
78
+ wait_for(:write, deadline, str.length)
79
+ rescue IO::WaitReadable
80
+ wait_for(:read, deadline, str.length)
78
81
  end
79
82
  end
80
- if len < str.length
81
- raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out writing #{str.length} bytes to #{@desc}")
82
- else
83
- len
84
- end
83
+
84
+ len
85
85
  end
86
86
  rescue TransportException => e
87
87
  # pass this on
@@ -94,25 +94,22 @@ module Thrift
94
94
  end
95
95
 
96
96
  def read(sz)
97
- raise IOError, "closed stream" unless open?
97
+ raise TransportException.new(TransportException::NOT_OPEN, "closed stream") unless open?
98
98
 
99
99
  begin
100
100
  if @timeout.nil? or @timeout == 0
101
101
  data = @handle.readpartial(sz)
102
102
  else
103
- # it's possible to interrupt select for something other than the timeout
104
- # so we need to ensure we've waited long enough, but not too long
105
- start = Time.now
106
- timespent = 0
107
- rd = loop do
108
- rd, = IO.select([@handle], nil, nil, @timeout - timespent)
109
- timespent = Time.now - start
110
- break rd if (rd and not rd.empty?) or timespent >= @timeout
111
- end
112
- if rd.nil? or rd.empty?
113
- raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out reading #{sz} bytes from #{@desc}")
114
- else
115
- data = @handle.readpartial(sz)
103
+ deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + @timeout
104
+
105
+ data = loop do
106
+ begin
107
+ break @handle.read_nonblock(sz)
108
+ rescue IO::WaitReadable
109
+ wait_for(:read, deadline, sz)
110
+ rescue IO::WaitWritable
111
+ wait_for(:write, deadline, sz)
112
+ end
116
113
  end
117
114
  end
118
115
  rescue TransportException => e
@@ -134,10 +131,40 @@ module Thrift
134
131
  @handle = nil
135
132
  end
136
133
 
137
- alias to_io handle
134
+ def to_io
135
+ @handle&.to_io || raise(IOError, 'closed stream')
136
+ end
138
137
 
139
138
  def to_s
140
139
  "socket(#{@host}:#{@port})"
141
140
  end
141
+
142
+ private
143
+
144
+ def wait_for(operation, deadline, sz)
145
+ rd_ary, wr_ary = case operation
146
+ when :read
147
+ [[@handle], nil]
148
+ when :write
149
+ [nil, [@handle]]
150
+ else
151
+ raise ArgumentError, "Unknown IO wait operation: #{operation.inspect}"
152
+ end
153
+
154
+ loop do
155
+ remaining = deadline - Process.clock_gettime(Process::CLOCK_MONOTONIC)
156
+ if remaining <= 0
157
+ case operation
158
+ when :read
159
+ raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out reading #{sz} bytes from #{@desc}")
160
+ when :write
161
+ raise TransportException.new(TransportException::TIMED_OUT, "Socket: Timed out writing #{sz} bytes to #{@desc}")
162
+ end
163
+ end
164
+
165
+ rd, wr, = IO.select(rd_ary, wr_ary, nil, remaining)
166
+ return if (rd && !rd.empty?) || (wr && !wr.empty?)
167
+ end
168
+ end
142
169
  end
143
170
  end
@@ -33,7 +33,7 @@ module Thrift
33
33
  socket = TCPServer.new(@host, @port)
34
34
  @handle = OpenSSL::SSL::SSLServer.new(socket, @ssl_context)
35
35
  end
36
-
36
+
37
37
  def to_s
38
38
  "ssl(#{super.to_s})"
39
39
  end
@@ -19,7 +19,7 @@
19
19
 
20
20
  module Thrift
21
21
  class SSLSocket < Socket
22
- def initialize(host='localhost', port=9090, timeout=nil, ssl_context=nil)
22
+ def initialize(host = 'localhost', port = 9090, timeout = nil, ssl_context = nil)
23
23
  super(host, port, timeout)
24
24
  @ssl_context = ssl_context
25
25
  end
@@ -43,7 +43,7 @@ module Thrift
43
43
  raise TransportException.new(TransportException::NOT_OPEN, "Could not connect to #{@desc}: #{e}")
44
44
  end
45
45
  end
46
-
46
+
47
47
  def to_s
48
48
  "ssl(#{super.to_s})"
49
49
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: ascii-8bit
2
- #
2
+ #
3
3
  # Licensed to the Apache Software Foundation (ASF) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -7,16 +7,16 @@
7
7
  # to you under the Apache License, Version 2.0 (the
8
8
  # "License"); you may not use this file except in compliance
9
9
  # with the License. You may obtain a copy of the License at
10
- #
10
+ #
11
11
  # http://www.apache.org/licenses/LICENSE-2.0
12
- #
12
+ #
13
13
  # Unless required by applicable law or agreed to in writing,
14
14
  # software distributed under the License is distributed on an
15
15
  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
16
  # KIND, either express or implied. See the License for the
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
- #
19
+ #
20
20
 
21
21
  require 'socket'
22
22
 
@@ -1,5 +1,5 @@
1
1
  # encoding: ascii-8bit
2
- #
2
+ #
3
3
  # Licensed to the Apache Software Foundation (ASF) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -7,22 +7,22 @@
7
7
  # to you under the Apache License, Version 2.0 (the
8
8
  # "License"); you may not use this file except in compliance
9
9
  # with the License. You may obtain a copy of the License at
10
- #
10
+ #
11
11
  # http://www.apache.org/licenses/LICENSE-2.0
12
- #
12
+ #
13
13
  # Unless required by applicable law or agreed to in writing,
14
14
  # software distributed under the License is distributed on an
15
15
  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
16
  # KIND, either express or implied. See the License for the
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
- #
19
+ #
20
20
 
21
21
  require 'socket'
22
22
 
23
23
  module Thrift
24
24
  class UNIXSocket < Socket
25
- def initialize(path, timeout=nil)
25
+ def initialize(path, timeout = nil)
26
26
  @path = path
27
27
  @timeout = timeout
28
28
  @desc = @path # for read()'s error
@@ -36,7 +36,7 @@ module Thrift
36
36
  raise TransportException.new(TransportException::NOT_OPEN, "Could not open UNIX socket at #{@path}")
37
37
  end
38
38
  end
39
-
39
+
40
40
  def to_s
41
41
  "domain(#{@path})"
42
42
  end
data/lib/thrift/types.rb CHANGED
@@ -1,4 +1,4 @@
1
- #
1
+ #
2
2
  # Licensed to the Apache Software Foundation (ASF) under one
3
3
  # or more contributor license agreements. See the NOTICE file
4
4
  # distributed with this work for additional information
@@ -6,16 +6,16 @@
6
6
  # to you under the Apache License, Version 2.0 (the
7
7
  # "License"); you may not use this file except in compliance
8
8
  # with the License. You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing,
13
13
  # software distributed under the License is distributed on an
14
14
  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
15
  # KIND, either express or implied. See the License for the
16
16
  # specific language governing permissions and limitations
17
17
  # under the License.
18
- #
18
+ #
19
19
 
20
20
  require 'set'
21
21
 
@@ -34,6 +34,7 @@ module Thrift
34
34
  MAP = 13
35
35
  SET = 14
36
36
  LIST = 15
37
+ UUID = 16
37
38
  end
38
39
 
39
40
  class << self
@@ -43,7 +44,7 @@ module Thrift
43
44
  class TypeError < Exception
44
45
  end
45
46
 
46
- def self.check_type(value, field, name, skip_nil=true)
47
+ def self.check_type(value, field, name, skip_nil = true)
47
48
  return if value.nil? and skip_nil
48
49
  klasses = case field[:type]
49
50
  when Types::VOID
@@ -56,6 +57,8 @@ module Thrift
56
57
  Float
57
58
  when Types::STRING
58
59
  String
60
+ when Types::UUID
61
+ String
59
62
  when Types::STRUCT
60
63
  [Struct, Union]
61
64
  when Types::MAP
@@ -70,7 +73,7 @@ module Thrift
70
73
  # check elements now
71
74
  case field[:type]
72
75
  when Types::MAP
73
- value.each_pair do |k,v|
76
+ value.each_pair do |k, v|
74
77
  check_type(k, field[:key], "#{name}.key", false)
75
78
  check_type(v, field[:value], "#{name}.value", false)
76
79
  end
data/lib/thrift/union.rb CHANGED
@@ -1,4 +1,4 @@
1
- #
1
+ #
2
2
  # Licensed to the Apache Software Foundation (ASF) under one
3
3
  # or more contributor license agreements. See the NOTICE file
4
4
  # distributed with this work for additional information
@@ -6,20 +6,20 @@
6
6
  # to you under the Apache License, Version 2.0 (the
7
7
  # "License"); you may not use this file except in compliance
8
8
  # with the License. You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing,
13
13
  # software distributed under the License is distributed on an
14
14
  # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
15
  # KIND, either express or implied. See the License for the
16
16
  # specific language governing permissions and limitations
17
17
  # under the License.
18
- #
18
+ #
19
19
 
20
20
  module Thrift
21
21
  class Union
22
- def initialize(name=nil, value=nil)
22
+ def initialize(name = nil, value = nil)
23
23
  if name
24
24
  if name.is_a? Hash
25
25
  if name.size > 1
@@ -60,7 +60,9 @@ module Thrift
60
60
  iprot.read_field_end
61
61
 
62
62
  fname, ftype, fid = iprot.read_field_begin
63
- raise "Too many fields for union" unless (ftype == Types::STOP)
63
+ unless (ftype == Types::STOP)
64
+ raise ProtocolException.new(ProtocolException::INVALID_DATA, "Too many fields for union")
65
+ end
64
66
 
65
67
  iprot.read_struct_end
66
68
  validate
@@ -73,6 +75,10 @@ module Thrift
73
75
  fid = self.name_to_id(@setfield.to_s)
74
76
 
75
77
  field_info = struct_fields[fid]
78
+ unless field_info
79
+ raise ProtocolException.new(ProtocolException::INVALID_DATA, "set_field is not valid for this union!")
80
+ end
81
+
76
82
  type = field_info[:type]
77
83
  if is_container? type
78
84
  oprot.write_field_begin(@setfield, type, fid)
@@ -99,7 +105,7 @@ module Thrift
99
105
  klass.send :define_method, field_info[:name] do
100
106
  if field_info[:name].to_sym == @setfield
101
107
  @value
102
- else
108
+ else
103
109
  raise RuntimeError, "#{field_info[:name]} is not union's set field."
104
110
  end
105
111
  end
@@ -124,7 +130,7 @@ module Thrift
124
130
  end
125
131
  end
126
132
 
127
- # get the symbol that indicates what the currently set field type is.
133
+ # get the symbol that indicates what the currently set field type is.
128
134
  def get_set_field
129
135
  @setfield
130
136
  end
@@ -0,0 +1,49 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require 'thrift/protocol/base_protocol'
21
+
22
+ module Thrift
23
+ module UUID
24
+ UUID_REGEX = /\A[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\z/.freeze
25
+
26
+ def self.validate_uuid!(uuid)
27
+ unless uuid.is_a?(String)
28
+ raise ProtocolException.new(ProtocolException::INVALID_DATA, 'UUID must be a string')
29
+ end
30
+
31
+ unless uuid =~ UUID_REGEX
32
+ raise ProtocolException.new(ProtocolException::INVALID_DATA, 'Invalid UUID format')
33
+ end
34
+ end
35
+
36
+ def self.uuid_bytes(uuid)
37
+ [uuid.delete('-')].pack('H*')
38
+ end
39
+
40
+ def self.uuid_from_bytes(bytes)
41
+ unless bytes.bytesize == 16
42
+ raise ProtocolException.new(ProtocolException::INVALID_DATA, 'Invalid UUID data length')
43
+ end
44
+
45
+ hex = bytes.unpack('H*').first
46
+ "#{hex[0, 8]}-#{hex[8, 4]}-#{hex[12, 4]}-#{hex[16, 4]}-#{hex[20, 12]}"
47
+ end
48
+ end
49
+ end
data/lib/thrift.rb CHANGED
@@ -23,7 +23,6 @@
23
23
  $:.unshift File.dirname(__FILE__)
24
24
 
25
25
  require 'thrift/bytes'
26
- require 'thrift/core_ext'
27
26
  require 'thrift/exceptions'
28
27
  require 'thrift/types'
29
28
  require 'thrift/processor'
@@ -32,6 +31,7 @@ require 'thrift/client'
32
31
  require 'thrift/struct'
33
32
  require 'thrift/union'
34
33
  require 'thrift/struct_union'
34
+ require 'thrift/uuid'
35
35
 
36
36
  # serializer
37
37
  require 'thrift/serializer/serializer'
@@ -44,6 +44,7 @@ require 'thrift/protocol/binary_protocol_accelerated'
44
44
  require 'thrift/protocol/compact_protocol'
45
45
  require 'thrift/protocol/json_protocol'
46
46
  require 'thrift/protocol/multiplexed_protocol'
47
+ require 'thrift/protocol/header_protocol'
47
48
 
48
49
  # transport
49
50
  require 'thrift/transport/base_transport'
@@ -56,6 +57,7 @@ require 'thrift/transport/unix_socket'
56
57
  require 'thrift/transport/unix_server_socket'
57
58
  require 'thrift/transport/buffered_transport'
58
59
  require 'thrift/transport/framed_transport'
60
+ require 'thrift/transport/header_transport'
59
61
  require 'thrift/transport/http_client_transport'
60
62
  require 'thrift/transport/io_stream_transport'
61
63
  require 'thrift/transport/memory_buffer_transport'
@@ -60,6 +60,7 @@ union TestUnion {
60
60
  3: i32 other_i32_field;
61
61
  4: SomeEnum enum_field;
62
62
  5: binary binary_field;
63
+ 6: uuid uuid_field;
63
64
  }
64
65
 
65
66
  struct Foo {
@@ -71,6 +72,7 @@ struct Foo {
71
72
  6: set<i16> shorts = [5, 17, 239],
72
73
  7: optional string opt_string
73
74
  8: bool my_bool
75
+ 9: optional uuid opt_uuid
74
76
  }
75
77
 
76
78
  struct Foo2 {
@@ -92,7 +94,8 @@ struct SimpleList {
92
94
  8: list<map<i16, i16>> maps,
93
95
  9: list<list<i16>> lists,
94
96
  10: list<set<i16>> sets,
95
- 11: list<Hello> hellos
97
+ 11: list<Hello> hellos,
98
+ 12: list<uuid> uuids
96
99
  }
97
100
 
98
101
  exception Xception {
@@ -119,6 +122,7 @@ union My_union {
119
122
  8: i32 other_i32
120
123
  9: SomeEnum some_enum;
121
124
  10: map<SomeEnum, list<SomeEnum>> my_map;
125
+ 11: uuid unique_id;
122
126
  }
123
127
 
124
128
  struct Struct_with_union {
@@ -20,7 +20,6 @@
20
20
  require 'spec_helper'
21
21
 
22
22
  describe 'BaseProtocol' do
23
-
24
23
  before(:each) do
25
24
  @trans = double("MockTransport")
26
25
  @prot = Thrift::BaseProtocol.new(@trans)
@@ -215,7 +214,7 @@ describe 'BaseProtocol' do
215
214
  describe Thrift::BaseProtocolFactory do
216
215
  it "should raise NotImplementedError" do
217
216
  # returning nil since Protocol is just an abstract class
218
- expect {Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport"))}.to raise_error(NotImplementedError)
217
+ expect { Thrift::BaseProtocolFactory.new.get_protocol(double("MockTransport")) }.to raise_error(NotImplementedError)
219
218
  end
220
219
 
221
220
  it "should provide a reasonable to_s" do
@@ -20,7 +20,6 @@
20
20
  require 'spec_helper'
21
21
 
22
22
  describe 'BaseTransport' do
23
-
24
23
  describe Thrift::TransportException do
25
24
  it "should make type accessible" do
26
25
  exc = Thrift::TransportException.new(Thrift::TransportException::ALREADY_OPEN, "msg")
@@ -48,7 +47,7 @@ describe 'BaseTransport' do
48
47
  it "should alias << to write" do
49
48
  expect(Thrift::BaseTransport.instance_method(:<<)).to eq(Thrift::BaseTransport.instance_method(:write))
50
49
  end
51
-
50
+
52
51
  it "should provide a reasonable to_s" do
53
52
  expect(Thrift::BaseTransport.new.to_s).to eq("base")
54
53
  end
@@ -67,7 +66,7 @@ describe 'BaseTransport' do
67
66
  transport = double("Transport")
68
67
  expect(Thrift::BaseTransportFactory.new.get_transport(transport)).to eql(transport)
69
68
  end
70
-
69
+
71
70
  it "should provide a reasonable to_s" do
72
71
  expect(Thrift::BaseTransportFactory.new.to_s).to eq("base")
73
72
  end
@@ -149,7 +148,7 @@ describe 'BaseTransport' do
149
148
  expect(Thrift::BufferedTransport).to receive(:new).with(trans).and_return(btrans)
150
149
  expect(Thrift::BufferedTransportFactory.new.get_transport(trans)).to eq(btrans)
151
150
  end
152
-
151
+
153
152
  it "should provide a reasonable to_s" do
154
153
  expect(Thrift::BufferedTransportFactory.new.to_s).to eq("buffered")
155
154
  end
@@ -271,7 +270,7 @@ describe 'BaseTransport' do
271
270
  expect(Thrift::FramedTransport).to receive(:new).with(trans)
272
271
  Thrift::FramedTransportFactory.new.get_transport(trans)
273
272
  end
274
-
273
+
275
274
  it "should provide a reasonable to_s" do
276
275
  expect(Thrift::FramedTransportFactory.new.to_s).to eq("framed")
277
276
  end
@@ -341,10 +340,10 @@ describe 'BaseTransport' do
341
340
 
342
341
  it "should throw an EOFError when there isn't enough data in the buffer" do
343
342
  @buffer.reset_buffer("")
344
- expect{@buffer.read(1)}.to raise_error(EOFError)
343
+ expect{ @buffer.read(1) }.to raise_error(EOFError)
345
344
 
346
345
  @buffer.reset_buffer("1234")
347
- expect{@buffer.read(5)}.to raise_error(EOFError)
346
+ expect{ @buffer.read(5) }.to raise_error(EOFError)
348
347
  end
349
348
  end
350
349
 
@@ -21,7 +21,6 @@ require 'spec_helper'
21
21
  require File.expand_path("#{File.dirname(__FILE__)}/binary_protocol_spec_shared")
22
22
 
23
23
  describe 'BinaryProtocol' do
24
-
25
24
  it_should_behave_like 'a binary protocol'
26
25
 
27
26
  def protocol_class
@@ -29,7 +28,6 @@ describe 'BinaryProtocol' do
29
28
  end
30
29
 
31
30
  describe Thrift::BinaryProtocol do
32
-
33
31
  before(:each) do
34
32
  @trans = Thrift::MemoryBufferTransport.new
35
33
  @prot = protocol_class.new(@trans)