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.



617
618
619
620
# File 'lib/fluent/plugin/out_groonga.rb', line 617

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

Instance Method Details

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



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

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



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

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

#startObject



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

def start
  @client = nil
end