Kouhei Sutou
null+****@clear*****
Thu Dec 19 17:10:02 JST 2013
Kouhei Sutou 2013-12-19 17:10:02 +0900 (Thu, 19 Dec 2013) New Revision: d190036d2369e03ff869037aa34da4fc69b4a2a8 https://github.com/droonga/fluent-plugin-droonga/commit/d190036d2369e03ff869037aa34da4fc69b4a2a8 Message: handler: remove needless codes Modified files: lib/droonga/handler.rb lib/droonga/handler_plugin.rb lib/droonga/plugin/handler/search.rb lib/droonga/plugin/handler/watch.rb Modified: lib/droonga/handler.rb (+16 -37) =================================================================== --- lib/droonga/handler.rb 2013-12-19 17:03:13 +0900 (67cbb7f) +++ lib/droonga/handler.rb 2013-12-19 17:10:02 +0900 (f2b4243) @@ -70,19 +70,26 @@ module Droonga :plugin => plugin.class) end - def emit(value, name = nil) - unless name - if @output_names - name = @output_names.first - else - @output_values = @task["values"] = value - return + def emit(value) + if****@desce*****? + forward(value, envelope["replyTo"]) + else + @descendants.each do |name, dests| + message = { + "id" => @id, + "input" => name, + "value" => value[name], + } + dests.each do |routes| + routes.each do |route| + forward(message, "to" => route, "type" => "dispatcher") + end + end end end - @output_values[name] = value end - def post(message, destination) + def forward(message, destination) @forwarder.forward(envelope, message, destination) end @@ -117,38 +124,10 @@ module Droonga @output_values = @task["values"] @body = @component["body"] - @output_names = @component["outputs"] @id = request["id"] - @value = request["value"] - @input_name = request["name"] @descendants = request["descendants"] plugin.process(command, @body, *arguments) - output if @descendants - true - end - - def output - result = @task["values"] - if @component["post"] - destination = @component["post"] - destination = envelope["replyTo"] if destination == true - if destination - post(result, destination) - end - end - @descendants.each do |name, dests| - message = { - "id" => @id, - "input" => name, - "value" => result[name] - } - dests.each do |routes| - routes.each do |route| - post(message, "to"=>route, "type"=>"dispatcher") - end - end - end end def log_tag Modified: lib/droonga/handler_plugin.rb (+4 -4) =================================================================== --- lib/droonga/handler_plugin.rb 2013-12-19 17:03:13 +0900 (91bdfd8) +++ lib/droonga/handler_plugin.rb 2013-12-19 17:10:02 +0900 (7534a81) @@ -31,12 +31,12 @@ module Droonga @handler.envelope end - def emit(value, name=nil) - @handler.emit(value, name) + def emit(value) + @handler.emit(value) end - def post(body, destination=nil) - @handler.post(body, destination) + def forward(body, destination) + @handler.forward(body, destination) end def prefer_synchronous?(command) Modified: lib/droonga/plugin/handler/search.rb (+3 -1) =================================================================== --- lib/droonga/plugin/handler/search.rb 2013-12-19 17:03:13 +0900 (22b465b) +++ lib/droonga/plugin/handler/search.rb 2013-12-19 17:10:02 +0900 (82b5432) @@ -25,9 +25,11 @@ module Droonga command :search def search(request) searcher = Droonga::Searcher.new(@context) + values = {} searcher.search(request["queries"]).each do |output, value| - emit(value, output) + values[output] = value end + emit(values) end end end Modified: lib/droonga/plugin/handler/watch.rb (+1 -1) =================================================================== --- lib/droonga/plugin/handler/watch.rb 2013-12-19 17:03:13 +0900 (c42b20f) +++ lib/droonga/plugin/handler/watch.rb 2013-12-19 17:10:02 +0900 (11edd96) @@ -76,7 +76,7 @@ module Droonga @watcher.feed(:targets => request["targets"]) do |route, subscribers| message = request # return request itself envelope["to"] = subscribers - post(message, "to" => route, "type" => "watch.notification") + forward(message, "to" => route, "type" => "watch.notification") end end -------------- next part -------------- HTML����������������������������... ダウンロード