Kouhei Sutou
null+****@clear*****
Tue Dec 24 16:31:08 JST 2013
Kouhei Sutou 2013-12-24 16:31:08 +0900 (Tue, 24 Dec 2013) New Revision: 5b22b698859d81f4c44352859b68d0a4435567bb https://github.com/droonga/fluent-plugin-droonga/commit/5b22b698859d81f4c44352859b68d0a4435567bb Message: Simplify "descendants" value in internal message Modified files: lib/droonga/dispatcher.rb lib/droonga/handler.rb lib/droonga/session.rb Modified: lib/droonga/dispatcher.rb (+6 -13) =================================================================== --- lib/droonga/dispatcher.rb 2013-12-24 15:52:50 +0900 (82a07ad) +++ lib/droonga/dispatcher.rb 2013-12-24 16:31:08 +0900 (b83174d) @@ -219,24 +219,17 @@ module Droonga component["n_of_expects"] = 0 end @components.each do |component| - descendants = get_descendants(component) - component["descendants"] = descendants - descendants.each do |key, indices| - indices.each do |index| + descendants = {} + (component["outputs"] || []).each do |output| + descendants[output] = [] + @descendants[output].each do |index| @components[index]["n_of_expects"] += component["routes"].size + descendants[output].concat(@components[index]["routes"]) end end + component["descendants"] = descendants end end - - def get_descendants(component) - return {} unless component["outputs"] - descendants = {} - component["outputs"].each do |output| - descendants[output] = @descendants[output] - end - descendants - end end end end Modified: lib/droonga/handler.rb (+2 -4) =================================================================== --- lib/droonga/handler.rb 2013-12-24 15:52:50 +0900 (f8bace1) +++ lib/droonga/handler.rb 2013-12-24 16:31:08 +0900 (93b339b) @@ -80,10 +80,8 @@ module Droonga "input" => name, "value" => value[name], } - dests.each do |routes| - routes.each do |route| - forward(message, "to" => route, "type" => "dispatcher") - end + dests.each do |dest| + forward(message, "to" => dest, "type" => "dispatcher") end end end Modified: lib/droonga/session.rb (+6 -10) =================================================================== --- lib/droonga/session.rb 2013-12-24 15:52:50 +0900 (5ce9d1e) +++ lib/droonga/session.rb 2013-12-24 16:31:08 +0900 (dd6317c) @@ -37,11 +37,9 @@ module Droonga command = component["command"] synchronous = nil descendants = {} - component["descendants"].each do |name, indices| - descendants[name] = indices.collect do |index| - @components[index]["routes"].map do |route| - @dispatcher.farm_path(route) - end + component["descendants"].each do |name, routes| + descendants[name] = routes.map do |route| + @dispatcher.farm_path(route) end end message = { @@ -77,16 +75,14 @@ module Droonga result = task["values"] post = component["post"] @dispatcher.reply(result) if post - component["descendants"].each do |name, indices| + component["descendants"].each do |name, routes| message = { "id" => @id, "input" => name, "value" => result[name] } - indices.each do |index| - @components[index]["routes"].each do |route| - @dispatcher.dispatch(message, route) - end + routes.each do |route| + @dispatcher.dispatch(message, route) end end @n_dones += 1 -------------- next part -------------- HTML����������������������������...Download