Kouhei Sutou
null+****@clear*****
Thu Dec 26 15:12:16 JST 2013
Kouhei Sutou 2013-12-26 15:12:16 +0900 (Thu, 26 Dec 2013) New Revision: 7d0ff38109dfd2fbff31bdbd57178e00076cab62 https://github.com/droonga/fluent-plugin-droonga/commit/7d0ff38109dfd2fbff31bdbd57178e00076cab62 Message: Make Dispatcher#reply more generic It is for encapsulating reply process. Modified files: lib/droonga/dispatcher.rb lib/droonga/session.rb Modified: lib/droonga/dispatcher.rb (+17 -5) =================================================================== --- lib/droonga/dispatcher.rb 2013-12-26 15:12:52 +0900 (27a1c59) +++ lib/droonga/dispatcher.rb 2013-12-26 15:12:16 +0900 (4d8d1f0) @@ -84,9 +84,8 @@ module Droonga assert_valid_message process_input_message(message) rescue MessageProcessingError => error - response = @output_adapter.adapt(@message.merge("statusCode" => error.status_code, - "body" => error.response_body)) - @replier.reply(response) + reply("statusCode" => error.status_code, + "body" => error.response_body) end end end @@ -97,8 +96,21 @@ module Droonga $log.trace("#{log_tag}: forward done") end - def reply(body) - adapted_message = @output_adapter.adapt(@message.merge("body" => body)) + # Replies response to replyTo. + # + # @param [Hash] message + # The message to be replied. See {Replier#reply} for available keys. + # + # The key-value pairs in request message are used as the default + # key-value pairs. For example, if the passed message doesn't + # include `id` key, `id` key's value is used in request message. + # + # @return [void] + # + # @see Replier#reply + def reply(message) + adapted_message = @output_adapter.adapt(@message.merge(message)) + return if adapted_message["replyTo"].nil? @replier.reply(adapted_message) end Modified: lib/droonga/session.rb (+1 -1) =================================================================== --- lib/droonga/session.rb 2013-12-26 15:12:52 +0900 (f117672) +++ lib/droonga/session.rb 2013-12-26 15:12:16 +0900 (ba11ac9) @@ -62,7 +62,7 @@ module Droonga #the task is done result = task["values"] post = component["post"] - @dispatcher.reply(result) if post + @dispatcher.reply("body" => result) if post component["descendants"].each do |name, routes| message = { "id" => @id, -------------- next part -------------- HTML����������������������������...Download