Class: Fluent::Plugin::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, output_plugin) ⇒ NetworkClient

Returns a new instance of NetworkClient.



642
643
644
645
646
# File 'lib/fluent/plugin/out_groonga.rb', line 642

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

Instance Method Details

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



654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
# File 'lib/fluent/plugin/out_groonga.rb', line 654

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

#shutdownObject



651
652
# File 'lib/fluent/plugin/out_groonga.rb', line 651

def shutdown
end

#startObject



648
649
# File 'lib/fluent/plugin/out_groonga.rb', line 648

def start
end