Class: Fluent::GroongaOutput::NetworkClient

Inherits:
BaseClient
  • Object
show all
Includes:
Configurable
Defined in:
lib/fluent/plugin/out_groonga.rb

Instance Method Summary collapse

Constructor Details

#initialize(protocol) ⇒ NetworkClient

Returns a new instance of NetworkClient.



620
621
622
623
# File 'lib/fluent/plugin/out_groonga.rb', line 620

def initialize(protocol)
  super()
  @protocol = protocol
end

Instance Method Details

#execute(name, arguments = {}) ⇒ Object



634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
# File 'lib/fluent/plugin/out_groonga.rb', line 634

def execute(name, arguments={})
  command = build_command(name, arguments)
  @client ||= Groonga::Client.new(:protocol => @protocol,
                                  :host     => @host,
                                  :port     => @port,
                                  :backend  => :synchronous)
  response = nil
  begin
    response = @client.execute(command)
  rescue Groonga::Client::Error
    $log.error("[output][groonga][error]",
               :protocol => @protocol,
               :host => @host,
               :port => @port,
               :command_name => name)
    raise
  end
  unless response.success?
    $log.error("[output][groonga][error]",
               :status_code => response.status_code,
               :message => response.message)
  end
  response
end

#shutdownObject



629
630
631
632
# File 'lib/fluent/plugin/out_groonga.rb', line 629

def shutdown
  return if @client.nil?
  @client.close
end

#startObject



625
626
627
# File 'lib/fluent/plugin/out_groonga.rb', line 625

def start
  @client = nil
end