rb: Tweak the benchmark to allow running the server in a separate process
Add a thin server library that can be run by hand
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@669021 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/benchmark/thin_server.rb b/lib/rb/benchmark/thin_server.rb
new file mode 100644
index 0000000..e7640a2
--- /dev/null
+++ b/lib/rb/benchmark/thin_server.rb
@@ -0,0 +1,25 @@
+$:.unshift File.dirname(__FILE__) + '/../lib'
+require 'thrift'
+require 'thrift/server/nonblockingserver'
+$:.unshift File.dirname(__FILE__) + "/gen-rb"
+require 'BenchmarkService'
+HOST = 'localhost'
+PORT = 42587
+
+class BenchmarkHandler
+ # 1-based index into the fibonacci sequence
+ def fibonacci(n)
+ seq = [1, 1]
+ 3.upto(n) do
+ seq << seq[-1] + seq[-2]
+ end
+ seq[n-1] # n is 1-based
+ end
+end
+
+handler = BenchmarkHandler.new
+processor = ThriftBenchmark::BenchmarkService::Processor.new(handler)
+transport = Thrift::ServerSocket.new(HOST, PORT)
+transportFactory = Thrift::FramedTransportFactory.new
+Thrift::NonblockingServer.new(processor, transport, transportFactory).serve
+