Kouhei Sutou
null+****@clear*****
Fri Dec 20 16:47:42 JST 2013
Kouhei Sutou 2013-12-20 16:47:42 +0900 (Fri, 20 Dec 2013) New Revision: 042c1291844459e0049353002959cf823b1e44f4 https://github.com/droonga/fluent-plugin-droonga/commit/042c1291844459e0049353002959cf823b1e44f4 Message: Use explicit method instead of general "post" for replying response Modified files: lib/droonga/collector.rb lib/droonga/dispatcher.rb lib/droonga/output_adapter.rb Modified: lib/droonga/collector.rb (+1 -1) =================================================================== --- lib/droonga/collector.rb 2013-12-20 16:24:50 +0900 (414178d) +++ lib/droonga/collector.rb 2013-12-20 16:47:42 +0900 (c2be942) @@ -83,7 +83,7 @@ module Droonga #the task is done result = task["values"] post = component["post"] - @dispatcher.post(result, post) if post + @dispatcher.reply(result) if post component["descendants"].each do |name, indices| message = { "id" => @id, Modified: lib/droonga/dispatcher.rb (+8 -6) =================================================================== --- lib/droonga/dispatcher.rb 2013-12-20 16:24:50 +0900 (f7eafb2) +++ lib/droonga/dispatcher.rb 2013-12-20 16:47:42 +0900 (3ebad45) @@ -76,11 +76,6 @@ module Droonga def post(body, destination=nil) $log.trace("#{log_tag}: post: start") - route = nil - unless is_route?(destination) - route = envelope["via"].pop - destination = route - end unless is_route?(destination) destination = envelope["replyTo"] end @@ -109,10 +104,17 @@ module Droonga @output_adapter.process(command, body, *arguments) end end - add_route(route) if route $log.trace("#{log_tag}: post: done") end + def reply(body) + @output_adapter.adapt(body) + if @envelope["via"].empty? + @forwarder.forward(@envelope.merge("body" => body), + @envelope["replyTo"]) + end + end + def handle_internal_message(message) id = message["id"] collector = @collectors[id] Modified: lib/droonga/output_adapter.rb (+9 -0) =================================================================== --- lib/droonga/output_adapter.rb 2013-12-20 16:24:50 +0900 (c3e1ad4) +++ lib/droonga/output_adapter.rb 2013-12-20 16:47:42 +0900 (6882b41) @@ -27,6 +27,15 @@ module Droonga load_plugins(options[:plugins] || []) end + def adapt(body) + @dispatcher.envelope["via"].reverse_each do |command| + @plugins.each do |plugin| + next unless plugin.processable?(command) + process(command, body) + end + end + end + private def instantiate_plugin(name) OutputAdapterPlugin.repository.instantiate(name, @dispatcher) -------------- next part -------------- HTML����������������������������...下載