Implemented header protocol for Ruby client library
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index 3340656..da73ba5 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -1473,6 +1473,12 @@
"py-rb_compact_framed-domain",
"py-rb_compact_framed-ip",
"py-rb_compact_framed-ip-ssl",
+ "py-rb_header_buffered-ip-ssl",
+ "py-rb_header_framed-ip-ssl",
+ "py-rb_header_framed-ip",
+ "py-rb_header_buffered-domain",
+ "py-rb_header_buffered-ip",
+ "py-rb_header_framed-domain",
"py-rb_json_buffered-domain",
"py-rb_json_buffered-ip",
"py-rb_json_buffered-ip-ssl",
@@ -1561,6 +1567,8 @@
"rb-py_compact-accelc_framed-ip-ssl",
"rb-py_compact_buffered-ip-ssl",
"rb-py_compact_framed-ip-ssl",
+ "rb-py_header_framed-ip-ssl",
+ "rb-py_header_buffered-ip-ssl",
"rb-py_json_buffered-ip-ssl",
"rb-py_json_framed-ip-ssl",
"rs-netstd_binary_buffered-ip",
diff --git a/test/rb/benchmarks/protocol_benchmark.rb b/test/rb/benchmarks/protocol_benchmark.rb
index 05a8ee5..7eee095 100644
--- a/test/rb/benchmarks/protocol_benchmark.rb
+++ b/test/rb/benchmarks/protocol_benchmark.rb
@@ -38,6 +38,16 @@
transport2 = Thrift::MemoryBuffer.new
c_fast_binary_protocol = Thrift::BinaryProtocolAccelerated.new(transport2)
+transport3 = Thrift::MemoryBuffer.new
+header_binary_protocol = Thrift::HeaderProtocol.new(transport3)
+
+transport4 = Thrift::MemoryBuffer.new
+header_compact_protocol = Thrift::HeaderProtocol.new(transport4, nil, Thrift::HeaderSubprotocolID::COMPACT)
+
+transport5 = Thrift::MemoryBuffer.new
+header_zlib_protocol = Thrift::HeaderProtocol.new(transport5)
+header_zlib_protocol.add_transform(Thrift::HeaderTransformID::ZLIB)
+
ooe = Fixtures::Structs::OneOfEach.new
ooe.im_true = true
@@ -170,5 +180,44 @@
Fixtures::Structs::OneOfEach.new.read(c_fast_binary_protocol)
end
end
-
+
+ x.report("header (binary) write 10_000 small structures") do
+ 10_000.times do
+ ooe.write(header_binary_protocol)
+ header_binary_protocol.trans.flush
+ end
+ end
+
+ x.report("header (binary) read 10_000 small structures") do
+ 10_000.times do
+ Fixtures::Structs::OneOfEach.new.read(header_binary_protocol)
+ end
+ end
+
+ x.report("header (compact) write 10_000 small structures") do
+ 10_000.times do
+ ooe.write(header_compact_protocol)
+ header_compact_protocol.trans.flush
+ end
+ end
+
+ x.report("header (compact) read 10_000 small structures") do
+ 10_000.times do
+ Fixtures::Structs::OneOfEach.new.read(header_compact_protocol)
+ end
+ end
+
+ x.report("header (zlib) write 10_000 small structures") do
+ 10_000.times do
+ ooe.write(header_zlib_protocol)
+ header_zlib_protocol.trans.flush
+ end
+ end
+
+ x.report("header (zlib) read 10_000 small structures") do
+ 10_000.times do
+ Fixtures::Structs::OneOfEach.new.read(header_zlib_protocol)
+ end
+ end
+
end
diff --git a/test/rb/integration/TestClient.rb b/test/rb/integration/TestClient.rb
index 1876529..ca54c8b 100755
--- a/test/rb/integration/TestClient.rb
+++ b/test/rb/integration/TestClient.rb
@@ -40,9 +40,9 @@
puts "\t--domain-socket arg (=) \t Unix domain socket path"
puts "\t--host arg (=localhost) \t Host to connect \t not valid with domain-socket"
puts "\t--port arg (=9090) \t Port number to listen \t not valid with domain-socket"
- puts "\t--protocol arg (=binary) \t protocol: accel, binary, compact, json"
+ puts "\t--protocol arg (=binary) \t protocol: accel, binary, compact, json, header"
puts "\t--ssl \t use ssl \t not valid with domain-socket"
- puts "\t--transport arg (=buffered) transport: buffered, framed, http"
+ puts "\t--transport arg (=buffered) transport: buffered, framed, header, http"
exit
elsif a.start_with?("--domain-socket")
$domain_socket = a.split("=")[1]
@@ -87,6 +87,8 @@
transportFactory = Thrift::BufferedTransport.new(@socket)
elsif $transport == "framed"
transportFactory = Thrift::FramedTransport.new(@socket)
+ elsif $transport == "header"
+ transportFactory = Thrift::HeaderTransport.new(@socket)
else
raise 'Unknown transport type'
end
@@ -99,6 +101,9 @@
@protocol = Thrift::JsonProtocol.new(transportFactory)
elsif $protocolType == "accel"
@protocol = Thrift::BinaryProtocolAccelerated.new(transportFactory)
+ elsif $protocolType == "header"
+ # HeaderProtocol wraps its own transport, so pass the selected transport
+ @protocol = Thrift::HeaderProtocol.new(transportFactory)
else
raise 'Unknown protocol type'
end
@@ -386,4 +391,3 @@
end
end
-
diff --git a/test/rb/integration/TestServer.rb b/test/rb/integration/TestServer.rb
index afa6c2d..65d1285 100755
--- a/test/rb/integration/TestServer.rb
+++ b/test/rb/integration/TestServer.rb
@@ -120,9 +120,9 @@
puts "\t -h [ --help ] \t produce help message"
puts "\t--domain-socket arg (=) \t Unix domain socket path"
puts "\t--port arg (=9090) \t Port number to listen \t not valid with domain-socket"
- puts "\t--protocol arg (=binary) \t protocol: accel, binary, compact, json"
+ puts "\t--protocol arg (=binary) \t protocol: accel, binary, compact, json, header"
puts "\t--ssl \t use ssl \t not valid with domain-socket"
- puts "\t--transport arg (=buffered) transport: buffered, framed, http"
+ puts "\t--transport arg (=buffered) transport: buffered, framed, header, http"
exit
elsif a.start_with?("--domain-socket")
domain_socket = a.split("=")[1]
@@ -145,6 +145,8 @@
@protocolFactory = Thrift::JsonProtocolFactory.new
elsif protocol == "accel"
@protocolFactory = Thrift::BinaryProtocolAcceleratedFactory.new
+elsif protocol == "header"
+ @protocolFactory = Thrift::HeaderProtocolFactory.new
else
raise 'Unknown protocol type'
end
@@ -153,6 +155,8 @@
@transportFactory = Thrift::BufferedTransportFactory.new
elsif transport == "framed"
@transportFactory = Thrift::FramedTransportFactory.new
+elsif transport == "header"
+ @transportFactory = Thrift::HeaderTransportFactory.new
else
raise 'Unknown transport type'
end
diff --git a/test/tests.json b/test/tests.json
index b0d7640..bcc87d3 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -457,7 +457,8 @@
"binary",
"binary:accel",
"compact",
- "json"
+ "json",
+ "header"
],
"workdir": "rb/gen-rb"
},