YUKI Hiroshi
null+****@clear*****
Fri Jan 24 14:13:57 JST 2014
YUKI Hiroshi 2014-01-24 14:13:57 +0900 (Fri, 24 Jan 2014) New Revision: 8979e7e2fe44c007d36469459ab1581c6d95d440 https://github.com/droonga/fluent-plugin-droonga/commit/8979e7e2fe44c007d36469459ab1581c6d95d440 Message: Add reducer and gatherer always Modified files: lib/droonga/distributor_plugin.rb Modified: lib/droonga/distributor_plugin.rb (+38 -14) =================================================================== --- lib/droonga/distributor_plugin.rb 2014-01-24 14:12:54 +0900 (8b35b64) +++ lib/droonga/distributor_plugin.rb 2014-01-24 14:13:57 +0900 (dd40814) @@ -31,7 +31,26 @@ module Droonga end def scatter_all(message, key) - distribute_message = { + messages = [reducer(message), gatherer(message), scatterer(message, key)] + distribute(messages) + end + + def broadcast_all(message) + messages = [reducer(message), gatherer(message), broadcaster(message)] + distribute(messages) + end + + private + def process_error(command, error, arguments) + if error.is_a?(MessageProcessingError) + raise error + else + super + end + end + + def scatterer(message, key) + { "command"=> message["type"], "dataset"=> message["dataset"], "body"=> message["body"], @@ -40,12 +59,10 @@ module Droonga "replica"=> "all", "post"=> true } - messages = [distribute_message] - distribute(messages) end - def broadcast_all(message) - distribute_message = { + def broadcaster(message) + { "command"=> message["type"], "dataset"=> message["dataset"], "body"=> message["body"], @@ -53,17 +70,24 @@ module Droonga "replica"=> "all", "post"=> true } - messages = [distribute_message] - distribute(messages) end - private - def process_error(command, error, arguments) - if error.is_a?(MessageProcessingError) - raise error - else - super - end + def reducer(message) + { + "type" => "reduce", + "body" => {}, + "inputs" => [], + "outputs" => [], + } + end + + def gatherer(message) + { + "type" => "gather", + "body" => {}, + "inputs" => [], + "post" => true, + } end end end -------------- next part -------------- HTML����������������������������...Download