[Groonga-commit] droonga/drnbench at af5d2b1 [master] Use droonga-client-ruby instead low level networking API

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Jan 20 15:35:41 JST 2014


YUKI Hiroshi	2014-01-20 15:35:41 +0900 (Mon, 20 Jan 2014)

  New Revision: af5d2b1d81b155307c175c9950f41f7a6cef6b04
  https://github.com/droonga/drnbench/commit/af5d2b1d81b155307c175c9950f41f7a6cef6b04

  Message:
    Use droonga-client-ruby instead low level networking API

  Modified files:
    lib/drnbench/client/http.rb
    lib/drnbench/publish-subscribe/runner.rb

  Modified: lib/drnbench/client/http.rb (+8 -17)
===================================================================
--- lib/drnbench/client/http.rb    2014-01-20 15:17:19 +0900 (38aa0c1)
+++ lib/drnbench/client/http.rb    2014-01-20 15:35:41 +0900 (aa1882f)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 require "thread"
-require "net/http"
+require "droonga/client"
 require "json"
 
 module Drnbench
@@ -20,22 +20,13 @@ module Drnbench
           request =****@reque*****
           request = fixup_request(request)
 
-          Net::HTTP.start(request["host"], request["port"]) do |http|
-            header = {
-              "user-agent" => "Ruby/#{RUBY_VERSION} Droonga::Benchmark::Runner::HttpClient"
-            }
-            response = nil
-            start_time = Time.now
-            case request["method"]
-            when "GET"
-              response = http.get(request["path"], header)
-            when "POST"
-              body = request["body"]
-              unless body.is_a?(String)
-                body = JSON.generate(body)
-              end
-              response = http.post(request["path"], body, header)
-            end
+          client = Droonga::Client.new(:protocol => :http,
+                                       :host => request["host"],
+                                       :port => request["port"])
+          message["headers"] ||= {}
+          message["headers"]["user-agent"] = "Ruby/#{RUBY_VERSION} Droonga::Benchmark::Runner::HttpClient"
+          start_time = Time.now
+          client.request(request) do |response|
             @result << {
               :request => request,
               :status => response.code,

  Modified: lib/drnbench/publish-subscribe/runner.rb (+4 -4)
===================================================================
--- lib/drnbench/publish-subscribe/runner.rb    2014-01-20 15:17:19 +0900 (0d352a2)
+++ lib/drnbench/publish-subscribe/runner.rb    2014-01-20 15:35:41 +0900 (4f70ef5)
@@ -72,10 +72,10 @@ module Drnbench
 
       def do_feed
         message =****@confi*****_feed
-        message[:id]         = Time.now.to_f.to_s,
-        message[:date]       = Time.now
-        message[:statusCode] = 200
-        @feeder.connection.send(message, :response => :none)
+        message["id"]         = Time.now.to_f.to_s,
+        message["date"]       = Time.now
+        message["statusCode"] = 200
+        @feeder.send(message, :response => :none)
       end
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index