Kouhei Sutou
null+****@clear*****
Tue Dec 17 23:42:36 JST 2013
Kouhei Sutou 2013-12-17 23:42:36 +0900 (Tue, 17 Dec 2013) New Revision: 3b9641d00cf49ae540161e1921ea7f66af837145 https://github.com/droonga/fluent-plugin-droonga/commit/3b9641d00cf49ae540161e1921ea7f66af837145 Message: Use "distribute" instead of generic "post" for distributor plugin API Modified files: lib/droonga/dispatcher.rb lib/droonga/distributor.rb lib/droonga/distributor_plugin.rb lib/droonga/plugin/distributor/search.rb test/unit/plugin/distributor/test_search.rb Modified: lib/droonga/dispatcher.rb (+4 -3) =================================================================== --- lib/droonga/dispatcher.rb 2013-12-17 23:42:01 +0900 (373254e) +++ lib/droonga/dispatcher.rb 2013-12-17 23:42:36 +0900 (17938c3) @@ -105,8 +105,9 @@ module Droonga elsif****@adapt*****?(command) @adapter.process(command, body, *arguments) else - @distributor.distribute(envelope.merge("type" => command, - "body" => body)) + @distributor.process(command, + envelope.merge("type" => command, + "body" => body)) end end add_route(route) if route @@ -204,7 +205,7 @@ module Droonga def process_input_message(envelope) adapted_envelope = apply_input_adapters(envelope) - @distributor.distribute(adapted_envelope) + @distributor.process(adapted_envelope["type"], adapted_envelope) end def log_tag Modified: lib/droonga/distributor.rb (+2 -7) =================================================================== --- lib/droonga/distributor.rb 2013-12-17 23:42:01 +0900 (bb79c0d) +++ lib/droonga/distributor.rb 2013-12-17 23:42:36 +0900 (f802210) @@ -30,13 +30,8 @@ module Droonga load_plugins(options[:distributors] || ["search", "crud", "groonga", "watch"]) end - def distribute(envelope) - command = envelope["type"] - process(command, envelope) - end - - def post(message) - @dispatcher.handle(message, []) + def distribute(message) + @dispatcher.handle_incoming_message(message) end private Modified: lib/droonga/distributor_plugin.rb (+4 -5) =================================================================== --- lib/droonga/distributor_plugin.rb 2013-12-17 23:42:01 +0900 (265e92f) +++ lib/droonga/distributor_plugin.rb 2013-12-17 23:42:36 +0900 (37380fd) @@ -26,9 +26,8 @@ module Droonga @distributor = distributor end - # TODO: consider better name - def post(message) - @distributor.post(message) + def distribute(message) + @distributor.distribute(message) end def scatter_all(envelope, key) @@ -41,7 +40,7 @@ module Droonga "replica"=> "all", "post"=> true }] - post(message) + distribute(message) end def broadcast_all(envelope) @@ -53,7 +52,7 @@ module Droonga "replica"=> "all", "post"=> true }] - post(distribute_message) + distribute(distribute_message) end end end Modified: lib/droonga/plugin/distributor/search.rb (+1 -1) =================================================================== --- lib/droonga/plugin/distributor/search.rb 2013-12-17 23:42:01 +0900 (db76874) +++ lib/droonga/plugin/distributor/search.rb 2013-12-17 23:42:36 +0900 (2fae701) @@ -25,7 +25,7 @@ module Droonga command :search def search(envelope) planner = DistributedSearchPlanner.new(envelope) - post(planner.messages) + distribute(planner.messages) end end end Modified: test/unit/plugin/distributor/test_search.rb (+3 -5) =================================================================== --- test/unit/plugin/distributor/test_search.rb 2013-12-17 23:42:01 +0900 (8af521d) +++ test/unit/plugin/distributor/test_search.rb 2013-12-17 23:42:36 +0900 (faefe3a) @@ -16,15 +16,13 @@ require "droonga/plugin/distributor/search" class SearchDistributorTest < Test::Unit::TestCase - include PluginHelper - def setup setup_database - setup_plugin(Droonga::SearchDistributor) + @distributor = Droonga::Test::StubDistributor.new + @plugin = Droonga::SearchDistributor.new(@distributor) end def teardown - teardown_plugin teardown_database end @@ -226,6 +224,6 @@ class SearchDistributorTest < Test::Unit::TestCase } message << searcher - assert_equal(message, @posted.last.last) + assert_equal([message], @distributor.messages) end end -------------- next part -------------- HTML����������������������������... Download