Kouhei Sutou
null+****@clear*****
Fri Feb 7 10:49:27 JST 2014
Kouhei Sutou 2014-02-07 10:49:27 +0900 (Fri, 07 Feb 2014) New Revision: 8c9c335c72cf0ac9709eda1d595cf676d8525c58 https://github.com/droonga/fluent-plugin-droonga/commit/8c9c335c72cf0ac9709eda1d595cf676d8525c58 Message: Add AdapterRunner Added files: lib/droonga/adapter_runner.rb Modified files: lib/droonga/dispatcher.rb Added: lib/droonga/adapter_runner.rb (+40 -0) 100644 =================================================================== --- /dev/null +++ lib/droonga/adapter_runner.rb 2014-02-07 10:49:27 +0900 (ad24cbf) @@ -0,0 +1,40 @@ +# Copyright (C) 2013-2014 Droonga Project +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +require "droonga/input_adapter" +require "droonga/output_adapter" + +module Droonga + class AdapterRunner + def initialize(dispatcher, input_adapter_options, output_adapter_options) + @dispatcher = dispatcher + @input_adapter = InputAdapter.new(self, input_adapter_options) + @output_adapter = OutputAdapter.new(self, output_adapter_options) + end + + def shutdown + @input_adapter.shutdown + @output_adapter.shutdown + end + + def adapt_input(message) + @input_adapter.adapt(message) + end + + def adapt_output(message) + @output_adapter.adapt(message) + end + end +end Modified: lib/droonga/dispatcher.rb (+7 -10) =================================================================== --- lib/droonga/dispatcher.rb 2014-02-07 10:48:20 +0900 (192b3f4) +++ lib/droonga/dispatcher.rb 2014-02-07 10:49:27 +0900 (c078d8d) @@ -16,8 +16,7 @@ require "English" require "tsort" -require "droonga/input_adapter" -require "droonga/output_adapter" +require "droonga/adapter_runner" require "droonga/planner" require "droonga/catalog" require "droonga/collector" @@ -52,10 +51,9 @@ module Droonga @sessions = {} @current_id = 0 @local = Regexp.new("^#{@name}") - @input_adapter = - InputAdapter.new(self, Droonga.catalog.input_adapter_options) - @output_adapter = - OutputAdapter.new(self, Droonga.catalog.output_adapter_options) + @adapter_runner = AdapterRunner.new(self, + Droonga.catalog.input_adapter_options, + Droonga.catalog.output_adapter_options) @farm = Farm.new(name, @loop, :dispatcher => self) @forwarder = Forwarder.new(@loop) @replier = Replier.new(@forwarder) @@ -75,8 +73,7 @@ module Droonga @forwarder.shutdown @planner.shutdown @collector.shutdown - @input_adapter.shutdown - @output_adapter.shutdown + @adapter_runner.shutdown @farm.shutdown @loop.stop @loop_thread.join @@ -121,7 +118,7 @@ module Droonga # # @see Replier#reply def reply(message) - adapted_message = @output_adapter.adapt(@message.merge(message)) + adapted_message = @adapter_runner.adapt_output(@message.merge(message)) return if adapted_message["replyTo"].nil? @replier.reply(adapted_message) end @@ -214,7 +211,7 @@ module Droonga end def process_input_message(message) - adapted_message = @input_adapter.adapt(message) + adapted_message = @adapter_runner.adapt_input(message) @planner.process(adapted_message["type"], adapted_message) rescue Droonga::Pluggable::UnknownPlugin => error raise UnknownCommand.new(error.command, message["dataset"]) -------------- next part -------------- HTML����������������������������... 다운로드