class Grntest::Executors::StandardIOExecutor

Constants

MAY_SLOW_COMMANDS
MAY_STREAM_OUTPUT_COMMANDS

Public Class Methods

new(input, output, context) click to toggle source
Calls superclass method Grntest::Executors::BaseExecutor::new
# File lib/grntest/executors/standard-io-executor.rb, line 21
def initialize(input, output, context)
  super(context)
  @input = input
  @output = output
end

Public Instance Methods

create_sub_executor(context) click to toggle source
# File lib/grntest/executors/standard-io-executor.rb, line 52
def create_sub_executor(context)
  self.class.new(@input, @output, context)
end
ensure_groonga_ready() click to toggle source
# File lib/grntest/executors/standard-io-executor.rb, line 46
def ensure_groonga_ready
  @input.print("status\n")
  @input.flush
  @raw_status_response = @output.gets
end
send_command(command) click to toggle source
# File lib/grntest/executors/standard-io-executor.rb, line 27
def send_command(command)
  command_line = command.original_source
  if !command.key?(:output_type) and @output_type
    command_line = command_line.sub(/$/, " --output_type #{@output_type}")
  end
  @benchmark_result.measure do
    begin
      debug_input(command_line)
      @input.print(command_line)
      @input.print("\n")
      @input.flush
    rescue SystemCallError
      message = "failed to write to groonga: <#{command_line}>: #{$!}"
      raise Error.new(message)
    end
    read_output(command)
  end
end

Private Instance Methods

may_slow_command?(command) click to toggle source
# File lib/grntest/executors/standard-io-executor.rb, line 77
def may_slow_command?(command)
  MAY_SLOW_COMMANDS.include?(command.name)
end
may_stream_output_command?(command) click to toggle source
# File lib/grntest/executors/standard-io-executor.rb, line 85
def may_stream_output_command?(command)
  MAY_STREAM_OUTPUT_COMMANDS.include?(command.name)
end
read_output(command) click to toggle source
# File lib/grntest/executors/standard-io-executor.rb, line 57
def read_output(command)
  options = {}
  if may_slow_command?(command)
    options[:first_timeout] = @long_read_timeout
  end
  if may_stream_output_command?(command)
    options[:stream_output] = true
  end
  read_all_readable_content(@output, options)
end