YUKI Hiroshi
null+****@clear*****
Thu Dec 26 12:47:18 JST 2013
YUKI Hiroshi 2013-12-26 12:47:18 +0900 (Thu, 26 Dec 2013) New Revision: 93c99969e46fbf57783c5950b8b7a150d8614c58 https://github.com/droonga/fluent-plugin-droonga/commit/93c99969e46fbf57783c5950b8b7a150d8614c58 Merged d5217b2: Merge branch 'master' of 192.168.1.21:~piro/groonga/fluent-plugin-droonga into HEAD Message: Handle HandlerError on the plugin layer Modified files: lib/droonga/handler.rb lib/droonga/handler_plugin.rb lib/droonga/plugin.rb Modified: lib/droonga/handler.rb (+1 -6) =================================================================== --- lib/droonga/handler.rb 2013-12-26 12:44:53 +0900 (cce9299) +++ lib/droonga/handler.rb 2013-12-26 12:47:18 +0900 (4bfaafd) @@ -20,7 +20,6 @@ require "groonga" require "droonga/forwarder" require "droonga/handler_message" require "droonga/handler_messenger" -require "droonga/handler_error" require "droonga/pluggable" require "droonga/handler_plugin" @@ -92,11 +91,7 @@ module Droonga handler_message.validate messenger = HandlerMessenger.new(@forwarder, handler_message, @options) - begin - plugin.process(command, handler_message, messenger) - rescue HandlerError => error - messenger.error(error.status_code, error.response_body) - end + plugin.process(command, handler_message, messenger) end def log_tag Modified: lib/droonga/handler_plugin.rb (+10 -0) =================================================================== --- lib/droonga/handler_plugin.rb 2013-12-26 12:44:53 +0900 (f621cd2) +++ lib/droonga/handler_plugin.rb 2013-12-26 12:47:18 +0900 (2f4b185) @@ -16,6 +16,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA require "droonga/plugin" +require "droonga/handler_error" module Droonga class HandlerPlugin < Plugin @@ -30,5 +31,14 @@ module Droonga def prefer_synchronous?(command) false end + + private + def run_command(command, message, messanger) + begin + super + rescue HandlerError => error + messenger.error(error.status_code, error.response_body) + end + end end end Modified: lib/droonga/plugin.rb (+6 -1) =================================================================== --- lib/droonga/plugin.rb 2013-12-26 12:44:53 +0900 (0745e5f) +++ lib/droonga/plugin.rb 2013-12-26 12:47:18 +0900 (f5e0cbd) @@ -33,11 +33,16 @@ module Droonga end def process(command, *arguments) - __send__(self.class.method_name(command), *arguments) + run_command(command, *arguments) rescue => exception Logger.error("error while processing #{command}", exception, arguments: arguments) end + + private + def run_command(command, *arguments) + __send__(self.class.method_name(command), *arguments) + end end end -------------- next part -------------- HTML����������������������������...Download