null+****@clear*****
null+****@clear*****
2012年 6月 6日 (水) 17:30:56 JST
Haruka Yoshihara 2012-06-06 17:30:56 +0900 (Wed, 06 Jun 2012)
New Revision: 9f2b35c30c79459ff02042dd67eebabceea76ea6
Log:
Move ensure_groonga_ready to executors
Modified files:
lib/groonga/tester.rb
Modified: lib/groonga/tester.rb (+20 -16)
===================================================================
--- lib/groonga/tester.rb 2012-06-06 17:25:50 +0900 (7b0832b)
+++ lib/groonga/tester.rb 2012-06-06 17:30:56 +0900 (c926a08)
@@ -304,8 +304,8 @@ module Groonga
begin
groonga_input = input_pipe[write]
groonga_output = output_pipe[read]
- ensure_groonga_ready(groonga_input, groonga_output)
executor = GQTPExecutor.new(groonga_input, groonga_output, context)
+ executor.ensure_groonga_ready
yield(executor)
ensure
(input_pipe + output_pipe).each do |io|
@@ -331,15 +331,7 @@ module Groonga
pid = Process.spawn(env, *command_line, options)
begin
executor = HTTPExecutor.new(host, port, context)
- n_retried = 0
- begin
- executor.send_command("status")
- rescue SystemCallError
- n_retried += 1
- sleep(0.1)
- retry if n_retried < 10
- raise
- end
+ executor.ensure_groonga_ready
yield(executor)
ensure
begin
@@ -350,12 +342,6 @@ module Groonga
end
end
- def ensure_groonga_ready(input, output)
- input.print("status\n")
- input.flush
- output.gets
- end
-
def normalize_result(result)
normalized_result = ""
result.each do |tag, content, options|
@@ -668,6 +654,12 @@ module Groonga
read_output
end
+ def ensure_groonga_ready
+ @input.print("status\n")
+ @input.flush
+ @output.gets
+ end
+
private
def read_output
output = ""
@@ -696,6 +688,18 @@ module Groonga
response.read
end
end
+
+ def ensure_groonga_ready
+ n_retried = 0
+ begin
+ send_command("status")
+ rescue SystemCallError
+ n_retried += 1
+ sleep(0.1)
+ retry if n_retried < 10
+ raise
+ end
+ end
end
class CommandFormatConverter