Kouhei Sutou
null+****@clear*****
Fri Jan 31 17:35:05 JST 2014
Kouhei Sutou 2014-01-31 17:35:05 +0900 (Fri, 31 Jan 2014) New Revision: 67d6faf36b5019a50918b1f0ba847c6ffb8d17fd https://github.com/droonga/fluent-plugin-droonga/commit/67d6faf36b5019a50918b1f0ba847c6ffb8d17fd Message: Don't require input adapter to apply output adapters Removed files: lib/droonga/plugin/input_adapter/crud.rb Modified files: lib/droonga/command_repository.rb lib/droonga/output_adapter.rb lib/droonga/plugin.rb lib/droonga/plugin/output_adapter/crud.rb lib/droonga/plugin_registerable.rb sample/cluster/catalog.json test/command/config/default/catalog.json Modified: lib/droonga/command_repository.rb (+1 -0) =================================================================== --- lib/droonga/command_repository.rb 2014-01-31 17:28:31 +0900 (ebe8764) +++ lib/droonga/command_repository.rb 2014-01-31 17:35:05 +0900 (ec39fc1) @@ -15,6 +15,7 @@ module Droonga class CommandRepository + attr_reader :commands def initialize @commands = [] end Modified: lib/droonga/output_adapter.rb (+17 -5) =================================================================== --- lib/droonga/output_adapter.rb 2014-01-31 17:28:31 +0900 (7e132f5) +++ lib/droonga/output_adapter.rb 2014-01-31 17:35:05 +0900 (cb364f8) @@ -37,14 +37,26 @@ module Droonga adapt_errors(output_message) adapted_message = output_message.adapted_message - message["via"].reverse_each do |command| + if message["via"].empty? @plugins.each do |plugin| - next unless plugin.processable?(command) - output_message = OutputMessage.new(adapted_message) - process(command, output_message) - adapted_message = output_message.adapted_message + plugin.class.commands.each do |command| + next unless command.match?(adapted_message) + output_message = OutputMessage.new(adapted_message) + plugin.process(command, output_message) + adapted_message = output_message.adapted_message + end + end + else + message["via"].reverse_each do |command| + @plugins.each do |plugin| + next unless plugin.processable?(command) + output_message = OutputMessage.new(adapted_message) + process(command, output_message) + adapted_message = output_message.adapted_message + end end end + adapted_message end Modified: lib/droonga/plugin.rb (+7 -2) =================================================================== --- lib/droonga/plugin.rb 2014-01-31 17:28:31 +0900 (4cd6e85) +++ lib/droonga/plugin.rb 2014-01-31 17:35:05 +0900 (062bc5e) @@ -40,11 +40,16 @@ module Droonga private def run_command(command, *arguments) - __send__(self.class.method_name(command), *arguments) + if command.is_a?(Command) + method_name = command.method_name + else + method_name = self.class.method_name(command) + end + __send__(method_name, *arguments) end def process_error(command, error, arguments) - Logger.error("error while processing #{command}", + Logger.error("error while processing: <#{command}>", error, :arguments => arguments) end Deleted: lib/droonga/plugin/input_adapter/crud.rb (+0 -27) 100644 =================================================================== --- lib/droonga/plugin/input_adapter/crud.rb 2014-01-31 17:28:31 +0900 (96fcbae) +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (C) 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_plugin" - -module Droonga - class CRUDInputAdapter < Droonga::InputAdapterPlugin - repository.register("crud", self) - - command :add - def add(input_message) - input_message.add_route("crud_generic_response") - end - end -end Modified: lib/droonga/plugin/output_adapter/crud.rb (+3 -2) =================================================================== --- lib/droonga/plugin/output_adapter/crud.rb 2014-01-31 17:28:31 +0900 (b77e2ac) +++ lib/droonga/plugin/output_adapter/crud.rb 2014-01-31 17:35:05 +0900 (aee59a8) @@ -19,8 +19,9 @@ module Droonga class CRUDOutputAdapter < Droonga::OutputAdapterPlugin repository.register("crud", self) - command :crud_generic_response - def crud_generic_response(output_message) + command :convert_success, + :patterns => [["replyTo.type", :equal, "add.result"]] + def convert_success(output_message) if output_message.body.include?("success") success = output_message.body["success"] unless success.nil? Modified: lib/droonga/plugin_registerable.rb (+4 -0) =================================================================== --- lib/droonga/plugin_registerable.rb 2014-01-31 17:28:31 +0900 (e9003c5) +++ lib/droonga/plugin_registerable.rb 2014-01-31 17:35:05 +0900 (3b2f210) @@ -54,6 +54,10 @@ module Droonga @command_repository.register(command) end + def commands + @command_repository.commands + end + def find_command(message) @command_repository.find(message) end Modified: sample/cluster/catalog.json (+1 -1) =================================================================== --- sample/cluster/catalog.json 2014-01-31 17:28:31 +0900 (ad986a2) +++ sample/cluster/catalog.json 2014-01-31 17:35:05 +0900 (f447386) @@ -39,7 +39,7 @@ } }, "input_adapter": { - "plugins": ["crud", "groonga"] + "plugins": ["groonga"] }, "output_adapter": { "plugins": ["crud", "groonga"] Modified: test/command/config/default/catalog.json (+1 -1) =================================================================== --- test/command/config/default/catalog.json 2014-01-31 17:28:31 +0900 (17b0153) +++ test/command/config/default/catalog.json 2014-01-31 17:35:05 +0900 (88eb533) @@ -56,7 +56,7 @@ } }, "input_adapter": { - "plugins": ["crud", "groonga"] + "plugins": ["groonga"] }, "output_adapter": { "plugins": ["crud", "groonga"] -------------- next part -------------- HTML����������������������������... Download