YUKI Hiroshi
null+****@clear*****
Thu Jul 17 18:04:13 JST 2014
YUKI Hiroshi 2014-07-17 18:04:13 +0900 (Thu, 17 Jul 2014) New Revision: d8e86b111766835d7c5953d4d0e99efd783cbc96 https://github.com/droonga/droonga-engine/commit/d8e86b111766835d7c5953d4d0e99efd783cbc96 Message: Send serf queries without spawning Modified files: lib/droonga/serf.rb Modified: lib/droonga/serf.rb (+19 -2) =================================================================== --- lib/droonga/serf.rb 2014-07-17 17:54:45 +0900 (1aefa07) +++ lib/droonga/serf.rb 2014-07-17 18:04:13 +0900 (1ab3643) @@ -17,6 +17,7 @@ require "English" require "json" require "coolio" +require "open3" require "droonga/path" require "droonga/loggable" @@ -108,12 +109,12 @@ module Droonga def send_event(event, payload) ensure_serf - run("event", event, JSON.generate(payload)).shutdown + run_once("event", event, JSON.generate(payload)) end def send_query(query, payload) ensure_serf - run("query", query, JSON.generate(payload)).shutdown + run_once("query", query, JSON.generate(payload)) end private @@ -145,6 +146,13 @@ module Droonga process end + def run_once(command, *options) + process = SerfProcess.new(@loop, @serf, command, + "-rpc-addr", rpc_address, + *options) + process.run_once + end + def extract_host(node_name) node_name.split(":").first end @@ -232,6 +240,15 @@ module Droonga not****@pid*****? end + def run_once + stdout, stderror, status = Open3.capture3(@serf, @command, *@options) + { + :output => stdout, + :error => stderror, + :status => status, + } + end + private def capture_output result = nil -------------- next part -------------- HTML����������������������������... 下载