Kouhei Sutou
null+****@clear*****
Mon Oct 20 16:31:19 JST 2014
Kouhei Sutou 2014-10-20 16:31:19 +0900 (Mon, 20 Oct 2014) New Revision: 978d5567fc650597948d25dc103fd07f3b2f7cf2 https://github.com/groonga/fluent-plugin-groonga/commit/978d5567fc650597948d25dc103fd07f3b2f7cf2 Message: Extract common code Modified files: lib/fluent/plugin/out_groonga.rb Modified: lib/fluent/plugin/out_groonga.rb (+13 -5) =================================================================== --- lib/fluent/plugin/out_groonga.rb 2014-10-20 16:29:41 +0900 (9e9a64f) +++ lib/fluent/plugin/out_groonga.rb 2014-10-20 16:31:19 +0900 (7c2e334) @@ -287,7 +287,15 @@ module Fluent end end - class NetworkClient + class BaseClient + private + def build_command(name, arguments={}) + command_class = Groonga::Command.find(name) + command_class.new(name, arguments) + end + end + + class NetworkClient < BaseClient include Configurable config_param :host, :string, :default => nil @@ -308,8 +316,7 @@ module Fluent end def send(name, arguments={}) - command_class = Groonga::Command.find(name) - command = command_class.new(name, arguments) + command = build_command(name, arguments) @client ||= Groonga::Client.new(:protocol => @protocol, :host => @host, :port => @port, @@ -318,7 +325,7 @@ module Fluent end end - class CommandClient + class CommandClient < BaseClient include Configurable config_param :groonga, :string, :default => "groonga" @@ -347,7 +354,8 @@ module Fluent Process.waitpid(@pid) end - def send(command) + def send(name, arguments={}) + command = build_command(name, arguments) body = nil if command.name == "load" body = command.arguments.delete(:values) -------------- next part -------------- HTML����������������������������...Download