Navigation Menu

Skip to content

Commit

Permalink
Pass loop to handler
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 11, 2014
1 parent 129e095 commit 1d206a5
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 12 deletions.
5 changes: 3 additions & 2 deletions lib/droonga/handler.rb
Expand Up @@ -35,11 +35,12 @@ def action
end
end

attr_reader :messenger
def initialize(name, context, messenger)
attr_reader :messenger, :loop
def initialize(name, context, messenger, loop)
@name = name
@context = context
@messenger = messenger
@loop = loop
end

def handle(message)
Expand Down
2 changes: 1 addition & 1 deletion lib/droonga/handler_runner.rb
Expand Up @@ -95,7 +95,7 @@ def process_type(handler_class, type, raw_message)
handler_message.validate

messenger = HandlerMessenger.new(@forwarder, handler_message, @options)
handler = handler_class.new(@name, @context, messenger)
handler = handler_class.new(@name, @context, messenger, @loop)
begin
result = handler.handle(handler_message)
unless result.nil?
Expand Down
4 changes: 3 additions & 1 deletion test/unit/plugins/crud/test_add.rb
Expand Up @@ -36,9 +36,11 @@ def setup_schema
def setup_handler
@worker = StubWorker.new
@messenger = Droonga::Test::StubHandlerMessenger.new
@loop = nil
@handler = Droonga::Plugins::CRUD::Handler.new("name",
@worker.context,
@messenger)
@messenger,
@loop)
end

def teardown_handler
Expand Down
3 changes: 2 additions & 1 deletion test/unit/plugins/groonga/test_column_create.rb
Expand Up @@ -17,7 +17,8 @@ class ColumnCreateTest < GroongaHandlerTest
def create_handler
Droonga::Plugins::Groonga::ColumnCreate::Handler.new("droonga",
@handler.context,
@messages)
@messages,
@loop)
end

def test_success
Expand Down
3 changes: 2 additions & 1 deletion test/unit/plugins/groonga/test_table_create.rb
Expand Up @@ -17,7 +17,8 @@ class TableCreateTest < GroongaHandlerTest
def create_handler
Droonga::Plugins::Groonga::TableCreate::Handler.new("droonga",
@handler.context,
@messenger)
@messenger,
@loop)
end

def test_success
Expand Down
3 changes: 2 additions & 1 deletion test/unit/plugins/groonga/test_table_remove.rb
Expand Up @@ -17,7 +17,8 @@ class TableRemoveTest < GroongaHandlerTest
def create_handler
Droonga::Plugins::Groonga::TableRemove::Handler.new("droonga",
@handler.context,
@messenger)
@messenger,
@loop)
end

def setup
Expand Down
4 changes: 3 additions & 1 deletion test/unit/plugins/search/test_handler.rb
Expand Up @@ -30,9 +30,11 @@ def teardown
def setup_plugin
@handler = Droonga::Test::StubHandler.new
@messenger = Droonga::Test::StubHandlerMessenger.new
@loop = nil
@plugin = Droonga::Plugins::Search::Handler.new("droonga",
@handler.context,
@messenger)
@messenger,
@loop)
end

def teardown_plugin
Expand Down
1 change: 1 addition & 0 deletions test/unit/plugins/test_groonga.rb
Expand Up @@ -32,6 +32,7 @@ def teardown
def setup_plugin
@handler = Droonga::Test::StubHandler.new
@messenger = Droonga::Test::StubHandlerMessenger.new
@loop = nil
end

def teardown_plugin
Expand Down
13 changes: 9 additions & 4 deletions test/unit/plugins/test_watch.rb
Expand Up @@ -37,6 +37,7 @@ def teardown
def setup_plugin
@handler = Droonga::Test::StubHandler.new
@messenger = Droonga::Test::StubHandlerMessenger.new
@loop = nil
end

def teardown_plugin
Expand All @@ -53,7 +54,8 @@ class SubscribeTest < self
def create_plugin
Droonga::Plugins::Watch::SubscribeHandler.new("droonga",
@handler.context,
@messenger)
@messenger,
@loop)
end

def test_subscribe
Expand Down Expand Up @@ -119,7 +121,8 @@ def setup
def create_plugin
Droonga::Plugins::Watch::UnsubscribeHandler.new("droonga",
@handler.context,
@messenger)
@messenger,
@loop)
end

def test_unsubscribe
Expand Down Expand Up @@ -153,7 +156,8 @@ def setup
def create_plugin
Droonga::Plugins::Watch::FeedHandler.new("droonga",
@handler.context,
@messenger)
@messenger,
@loop)
end

def test_feed_match
Expand Down Expand Up @@ -198,7 +202,8 @@ def setup_subscription
subscribe_handler =
Droonga::Plugins::Watch::SubscribeHandler.new("droonga",
@handler.context,
@messenger)
@messenger,
@loop)
response = subscribe_handler.handle(message)
assert_equal(SUCCESS_RESULT, response)
end
Expand Down

0 comments on commit 1d206a5

Please sign in to comment.