Class: GroongaDelta::LocalDelta::CommandProcessor

Inherits:
Groonga::Client::CommandProcessor
  • Object
show all
Defined in:
lib/groonga-delta/local-delta.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, *args) ⇒ CommandProcessor

Returns a new instance of CommandProcessor.



342
343
344
345
# File 'lib/groonga-delta/local-delta.rb', line 342

def initialize(config, *args)
  @config = config
  super(*args)
end

Instance Method Details

#process_response(response, command) ⇒ Object



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/groonga-delta/local-delta.rb', line 347

def process_response(response, command)
  message = ""
  case command.command_name
  when "load"
    command.arguments.delete(:values)
    if response.success?
      message = "#{response.n_loaded_records}: "
    else
      load_response = Groonga::Client::Response::Load.new(command,
                                                          response.header,
                                                          response.body)
      message = "#{load_response.n_loaded_records}: "
    end
  end
  if response.success?
    @config.logger.info("Processed: " +
                        "#{response.elapsed_time}: " +
                        "#{command.command_name}: " +
                        message +
                        "#{command.to_command_format}")
  else
    failed_message = "Failed to process: " +
                     "#{response.return_code}: " +
                     "#{response.elapsed_time}: " +
                     "#{response.error_message}: " +
                     "#{command.command_name}: " +
                     message +
                     "#{command.to_command_format}"
    case @config.on_error
    when "ignore"
    when "warning"
      @config.logger.warn(failed_message)
    when "error"
      raise ExecutionError, failed_message
    end
  end
end