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
@@ -0,0 +1,320 @@
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
+ module Thrift
22
+ # HeaderProtocol is a protocol that wraps HeaderTransport and delegates
23
+ # to either BinaryProtocol or CompactProtocol based on auto-detection.
24
+ #
25
+ # It provides access to header management (get_headers, set_header, etc.)
26
+ # through the underlying HeaderTransport.
27
+ #
28
+ # Example usage:
29
+ # socket = Thrift::Socket.new('localhost', 9090)
30
+ # protocol = Thrift::HeaderProtocol.new(socket)
31
+ # client = MyService::Client.new(protocol)
32
+ # protocol.trans.open
33
+ # client.some_method()
34
+ # protocol.trans.close
35
+ #
36
+ class HeaderProtocol < BaseProtocol
37
+ # Creates a new HeaderProtocol.
38
+ #
39
+ # @param transport [BaseTransport, HeaderTransport] The transport to wrap.
40
+ # If not already a HeaderTransport, it will be wrapped in one.
41
+ # @param allowed_client_types [Array<Integer>] Allowed client types for auto-detection
42
+ # @param default_protocol [Integer] Default protocol ID (BINARY or COMPACT)
43
+ def initialize(transport, allowed_client_types = nil, default_protocol = HeaderSubprotocolID::COMPACT)
44
+ # Wrap transport in HeaderTransport if not already wrapped
45
+ if transport.is_a?(HeaderTransport)
46
+ @header_transport = transport
47
+ else
48
+ @header_transport = HeaderTransport.new(transport, allowed_client_types, default_protocol)
49
+ end
50
+
51
+ @default_protocol = default_protocol
52
+ @current_protocol_id = default_protocol
53
+
54
+ # Create initial protocol
55
+ @protocol = create_protocol(@current_protocol_id)
56
+ end
57
+
58
+ # Returns the HeaderTransport
59
+ def trans
60
+ @header_transport
61
+ end
62
+
63
+ # Returns headers read from the last message
64
+ def get_headers
65
+ @header_transport.get_headers
66
+ end
67
+
68
+ # Sets a header to be sent with the next message
69
+ def set_header(key, value)
70
+ @header_transport.set_header(key, value)
71
+ end
72
+
73
+ # Clears all write headers
74
+ def clear_headers
75
+ @header_transport.clear_headers
76
+ end
77
+
78
+ # Adds a transform (e.g., ZLIB compression)
79
+ def add_transform(transform_id)
80
+ @header_transport.add_transform(transform_id)
81
+ end
82
+
83
+ # Write methods - delegate to underlying protocol
84
+ def write_message_begin(name, type, seqid)
85
+ @header_transport.sequence_id = seqid
86
+ @protocol.write_message_begin(name, type, seqid)
87
+ end
88
+
89
+ def write_message_end
90
+ @protocol.write_message_end
91
+ end
92
+
93
+ def write_struct_begin(name)
94
+ @protocol.write_struct_begin(name)
95
+ end
96
+
97
+ def write_struct_end
98
+ @protocol.write_struct_end
99
+ end
100
+
101
+ def write_field_begin(name, type, id)
102
+ @protocol.write_field_begin(name, type, id)
103
+ end
104
+
105
+ def write_field_end
106
+ @protocol.write_field_end
107
+ end
108
+
109
+ def write_field_stop
110
+ @protocol.write_field_stop
111
+ end
112
+
113
+ def write_map_begin(ktype, vtype, size)
114
+ @protocol.write_map_begin(ktype, vtype, size)
115
+ end
116
+
117
+ def write_map_end
118
+ @protocol.write_map_end
119
+ end
120
+
121
+ def write_list_begin(etype, size)
122
+ @protocol.write_list_begin(etype, size)
123
+ end
124
+
125
+ def write_list_end
126
+ @protocol.write_list_end
127
+ end
128
+
129
+ def write_set_begin(etype, size)
130
+ @protocol.write_set_begin(etype, size)
131
+ end
132
+
133
+ def write_set_end
134
+ @protocol.write_set_end
135
+ end
136
+
137
+ def write_bool(bool)
138
+ @protocol.write_bool(bool)
139
+ end
140
+
141
+ def write_byte(byte)
142
+ @protocol.write_byte(byte)
143
+ end
144
+
145
+ def write_i16(i16)
146
+ @protocol.write_i16(i16)
147
+ end
148
+
149
+ def write_i32(i32)
150
+ @protocol.write_i32(i32)
151
+ end
152
+
153
+ def write_i64(i64)
154
+ @protocol.write_i64(i64)
155
+ end
156
+
157
+ def write_double(dub)
158
+ @protocol.write_double(dub)
159
+ end
160
+
161
+ def write_string(str)
162
+ @protocol.write_string(str)
163
+ end
164
+
165
+ def write_binary(buf)
166
+ @protocol.write_binary(buf)
167
+ end
168
+
169
+ def write_uuid(uuid)
170
+ @protocol.write_uuid(uuid)
171
+ end
172
+
173
+ # Read methods - delegate to underlying protocol
174
+ # read_message_begin handles protocol switching after detection
175
+ def read_message_begin
176
+ begin
177
+ @header_transport.reset_protocol
178
+ reset_protocol_if_needed
179
+ rescue ProtocolException => ex
180
+ app_ex = ApplicationException.new(ApplicationException::INVALID_PROTOCOL, ex.message)
181
+ write_message_begin("", MessageTypes::EXCEPTION, 0)
182
+ app_ex.write(self)
183
+ write_message_end
184
+ @header_transport.flush
185
+ raise ex
186
+ end
187
+ @protocol.read_message_begin
188
+ end
189
+
190
+ def read_message_end
191
+ @protocol.read_message_end
192
+ end
193
+
194
+ def read_struct_begin
195
+ @protocol.read_struct_begin
196
+ end
197
+
198
+ def read_struct_end
199
+ @protocol.read_struct_end
200
+ end
201
+
202
+ def read_field_begin
203
+ @protocol.read_field_begin
204
+ end
205
+
206
+ def read_field_end
207
+ @protocol.read_field_end
208
+ end
209
+
210
+ def read_map_begin
211
+ @protocol.read_map_begin
212
+ end
213
+
214
+ def read_map_end
215
+ @protocol.read_map_end
216
+ end
217
+
218
+ def read_list_begin
219
+ @protocol.read_list_begin
220
+ end
221
+
222
+ def read_list_end
223
+ @protocol.read_list_end
224
+ end
225
+
226
+ def read_set_begin
227
+ @protocol.read_set_begin
228
+ end
229
+
230
+ def read_set_end
231
+ @protocol.read_set_end
232
+ end
233
+
234
+ def read_bool
235
+ @protocol.read_bool
236
+ end
237
+
238
+ def read_byte
239
+ @protocol.read_byte
240
+ end
241
+
242
+ def read_i16
243
+ @protocol.read_i16
244
+ end
245
+
246
+ def read_i32
247
+ @protocol.read_i32
248
+ end
249
+
250
+ def read_i64
251
+ @protocol.read_i64
252
+ end
253
+
254
+ def read_double
255
+ @protocol.read_double
256
+ end
257
+
258
+ def read_string
259
+ @protocol.read_string
260
+ end
261
+
262
+ def read_binary
263
+ @protocol.read_binary
264
+ end
265
+
266
+ def read_uuid
267
+ @protocol.read_uuid
268
+ end
269
+
270
+ def to_s
271
+ "header(#{@protocol.to_s})"
272
+ end
273
+
274
+ private
275
+
276
+ # Checks if the protocol needs to be switched after reading
277
+ def reset_protocol_if_needed
278
+ new_protocol_id = @header_transport.protocol_id
279
+ if new_protocol_id != @current_protocol_id
280
+ @protocol = create_protocol(new_protocol_id)
281
+ @current_protocol_id = new_protocol_id
282
+ end
283
+ end
284
+
285
+ # Creates a protocol instance based on protocol ID
286
+ def create_protocol(protocol_id)
287
+ case protocol_id
288
+ when HeaderSubprotocolID::BINARY
289
+ BinaryProtocol.new(@header_transport)
290
+ when HeaderSubprotocolID::COMPACT
291
+ CompactProtocol.new(@header_transport)
292
+ else
293
+ raise ProtocolException.new(
294
+ ProtocolException::INVALID_DATA,
295
+ "Unknown protocol ID: #{protocol_id}"
296
+ )
297
+ end
298
+ end
299
+ end
300
+
301
+ # Factory for creating HeaderProtocol instances
302
+ class HeaderProtocolFactory < BaseProtocolFactory
303
+ # Creates a new HeaderProtocolFactory.
304
+ #
305
+ # @param allowed_client_types [Array<Integer>] Allowed client types for auto-detection
306
+ # @param default_protocol [Integer] Default protocol ID (BINARY or COMPACT)
307
+ def initialize(allowed_client_types = nil, default_protocol = HeaderSubprotocolID::BINARY)
308
+ @allowed_client_types = allowed_client_types
309
+ @default_protocol = default_protocol
310
+ end
311
+
312
+ def get_protocol(trans)
313
+ HeaderProtocol.new(trans, @allowed_client_types, @default_protocol)
314
+ end
315
+
316
+ def to_s
317
+ "header"
318
+ end
319
+ end
320
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: UTF-8
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,18 +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
- #
20
-
21
- require 'base64'
19
+ #
22
20
 
23
21
  module Thrift
24
22
  class LookaheadReader
@@ -181,6 +179,8 @@ module Thrift
181
179
  "set"
182
180
  when Types::LIST
183
181
  "lst"
182
+ when Types::UUID
183
+ "uid"
184
184
  else
185
185
  raise NotImplementedError
186
186
  end
@@ -209,6 +209,8 @@ module Thrift
209
209
  result = Types::SET
210
210
  elsif (name == "lst")
211
211
  result = Types::LIST
212
+ elsif (name == "uid")
213
+ result = Types::UUID
212
214
  else
213
215
  result = Types::STOP
214
216
  end
@@ -255,7 +257,7 @@ module Thrift
255
257
  if (ch_value.kind_of? String)
256
258
  ch_value = ch.bytes.first
257
259
  end
258
- trans.write(ch_value.to_s(16).rjust(4,'0'))
260
+ trans.write(ch_value.to_s(16).rjust(4, '0'))
259
261
  end
260
262
 
261
263
  # Write the character ch as part of a JSON string, escaping as appropriate.
@@ -266,9 +268,9 @@ module Thrift
266
268
  # <other> : escape using "\<other>" notation
267
269
  kJSONCharTable = [
268
270
  # 0 1 2 3 4 5 6 7 8 9 A B C D E F
269
- 0, 0, 0, 0, 0, 0, 0, 0,'b','t','n', 0,'f','r', 0, 0, # 0
271
+ 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, # 0
270
272
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, # 1
271
- 1, 1,'"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 2
273
+ 1, 1, '"', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, # 2
272
274
  ]
273
275
 
274
276
  ch_value = ch[0]
@@ -311,7 +313,7 @@ module Thrift
311
313
  def write_json_base64(str)
312
314
  @context.write(trans)
313
315
  trans.write(@@kJSONStringDelimiter)
314
- trans.write(Base64.strict_encode64(str))
316
+ trans.write([str].pack('m0'))
315
317
  trans.write(@@kJSONStringDelimiter)
316
318
  end
317
319
 
@@ -477,6 +479,11 @@ module Thrift
477
479
  write_json_base64(str)
478
480
  end
479
481
 
482
+ def write_uuid(uuid)
483
+ UUID.validate_uuid!(uuid)
484
+ write_json_string(uuid.downcase)
485
+ end
486
+
480
487
  ##
481
488
  # Reading functions
482
489
  ##
@@ -497,11 +504,7 @@ module Thrift
497
504
  str += @reader.read
498
505
  str += @reader.read
499
506
  str += @reader.read
500
- if RUBY_VERSION >= '1.9'
501
- str.hex.chr(Encoding::UTF_8)
502
- else
503
- str.hex.chr
504
- end
507
+ str.hex.chr(Encoding::UTF_8)
505
508
  end
506
509
 
507
510
  # Decodes a JSON string, including unescaping, and returns the string via str
@@ -555,7 +558,7 @@ module Thrift
555
558
  str += '='
556
559
  end
557
560
  end
558
- Base64.strict_decode64(str)
561
+ str.unpack1('m0')
559
562
  end
560
563
 
561
564
  # Reads a sequence of characters, stopping at the first one that is not
@@ -769,6 +772,13 @@ module Thrift
769
772
  read_json_base64
770
773
  end
771
774
 
775
+ def read_uuid
776
+ uuid = read_json_string
777
+ raise EOFError.new if uuid.length < 36
778
+ UUID.validate_uuid!(uuid)
779
+ uuid.tap(&:downcase!)
780
+ end
781
+
772
782
  def to_s
773
783
  "json(#{super.to_s})"
774
784
  end
@@ -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,9 +6,9 @@
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
@@ -34,9 +34,9 @@ module Thrift
34
34
  @protocol.write_message_begin("#{@service_name}:#{name}", type, seqid)
35
35
  else
36
36
  @protocol.write_message_begin(name, type, seqid)
37
- end
37
+ end
38
38
  end
39
-
39
+
40
40
  def to_s
41
41
  "multiplexed(#{@service_name=@protocol.to_s})"
42
42
  end
@@ -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,9 +6,9 @@
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
@@ -111,6 +111,10 @@ module Thrift
111
111
  @protocol.write_binary(buf)
112
112
  end
113
113
 
114
+ def write_uuid(uuid)
115
+ @protocol.write_uuid(uuid)
116
+ end
117
+
114
118
  def read_message_begin
115
119
  @protocol.read_message_begin
116
120
  end
@@ -190,5 +194,9 @@ module Thrift
190
194
  def read_binary
191
195
  @protocol.read_binary
192
196
  end
197
+
198
+ def read_uuid
199
+ @protocol.read_uuid
200
+ end
193
201
  end
194
- end
202
+ end
@@ -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
  module Thrift
21
21
  class Deserializer
@@ -30,4 +30,4 @@ module Thrift
30
30
  base
31
31
  end
32
32
  end
33
- end
33
+ end
@@ -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
  module Thrift
21
21
  class Serializer
@@ -31,4 +31,3 @@ module Thrift
31
31
  end
32
32
  end
33
33
  end
34
-
@@ -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,9 +6,9 @@
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
@@ -19,7 +19,7 @@
19
19
 
20
20
  module Thrift
21
21
  class BaseServer
22
- def initialize(processor, server_transport, transport_factory=nil, protocol_factory=nil)
22
+ def initialize(processor, server_transport, transport_factory = nil, protocol_factory = nil)
23
23
  @processor = processor
24
24
  @server_transport = server_transport
25
25
  @transport_factory = transport_factory ? transport_factory : Thrift::BaseTransportFactory.new
@@ -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 'mongrel'
21
21
 
@@ -38,12 +38,12 @@ module Thrift
38
38
  @processor.process protocol, protocol
39
39
  end
40
40
  else
41
- response.start(404) { }
41
+ response.start(404) {}
42
42
  end
43
43
  end
44
44
  end
45
45
 
46
- def initialize(processor, opts={})
46
+ def initialize(processor, opts = {})
47
47
  Kernel.warn "[DEPRECATION WARNING] `Thrift::MongrelHTTPServer` is deprecated. Please use `Thrift::ThinHTTPServer` instead."
48
48
  port = opts[:port] || 80
49
49
  ip = opts[:ip] || "0.0.0.0"
@@ -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 'logger'
21
21
  require 'thread'
@@ -23,7 +23,7 @@ require 'thread'
23
23
  module Thrift
24
24
  # this class expects to always use a FramedTransport for reading messages
25
25
  class NonblockingServer < BaseServer
26
- def initialize(processor, server_transport, transport_factory=nil, protocol_factory=nil, num=20, logger=nil)
26
+ def initialize(processor, server_transport, transport_factory = nil, protocol_factory = nil, num = 20, logger = nil)
27
27
  super(processor, server_transport, transport_factory, protocol_factory)
28
28
  @num_threads = num
29
29
  if logger.nil?
@@ -97,7 +97,7 @@ module Thrift
97
97
 
98
98
  class IOManager # :nodoc:
99
99
  DEFAULT_BUFFER = 2**20
100
-
100
+
101
101
  def initialize(processor, server_transport, transport_factory, protocol_factory, num, logger)
102
102
  @processor = processor
103
103
  @server_transport = server_transport
@@ -106,7 +106,7 @@ module Thrift
106
106
  @num_threads = num
107
107
  @logger = logger
108
108
  @connections = []
109
- @buffers = Hash.new { |h,k| h[k] = '' }
109
+ @buffers = Hash.new { |h, k| h[k] = '' }
110
110
  @signal_queue = Queue.new
111
111
  @signal_pipes = IO.pipe
112
112
  @signal_pipes[1].sync = true
@@ -142,7 +142,7 @@ module Thrift
142
142
  end
143
143
 
144
144
  private
145
-
145
+
146
146
  def run
147
147
  spin_worker_threads
148
148