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.



602
603
604
605
# File 'lib/fluent/plugin/out_groonga.rb', line 602

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

Instance Method Details

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



616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
# File 'lib/fluent/plugin/out_groonga.rb', line 616

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



611
612
613
614
# File 'lib/fluent/plugin/out_groonga.rb', line 611

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

#startObject



607
608
609
# File 'lib/fluent/plugin/out_groonga.rb', line 607

def start
  @client = nil
end