Permalink
Browse files

added shutdown method for client

  • Loading branch information...
1 parent fbfa9f2 commit c60e5b5faf5d8870e5116047429e6d41d3e4a9bd @arya committed Aug 5, 2009
Showing with 7 additions and 2 deletions.
  1. +5 −1 lib/pandemic/client_side/cluster_connection.rb
  2. +2 −1 test/functional_test.rb
@@ -7,7 +7,6 @@ class LostConnectionToNode < StandardError; end
class NodeTimedOut < StandardError; end
class RequestFailed < StandardError; end
-
include Util
def initialize
Config.load
@@ -71,6 +70,11 @@ def request(body, key = nil, options = {})
end
end
+ def shutdown
+ @connections.each {|c| c.socket.close if c.alive? }
+ @maintain_minimum_connections_thread.kill if @maintain_minimum_connections_thread
+ end
+
private
def with_connection(key, &block)
connection = nil
View
@@ -6,7 +6,6 @@ class FunctionalTest < Test::Unit::TestCase
ignore_threads = Thread.list
ARGV.replace(["-i", "0", "-c", "test/pandemic_server.yml"]) # :(
Pandemic::ClientSide::Config.config_path = "test/pandemic_client.yml"
-
server = epidemic!
server.handler = Class.new(Pandemic::ServerSide::Handler) do
def process(body)
@@ -20,6 +19,7 @@ def process(body)
end.new
client.extend(Pandemize)
assert_equal "dlrow olleh", client.pandemic.request("hello world")
+ client.pandemic.shutdown
server.stop
wait_for_threads(ignore_threads)
end
@@ -49,6 +49,7 @@ def process(body)
end.new
client.extend(Pandemize)
assert_equal "raboofraboof", client.pandemic.request("foobar")
+ client.pandemic.shutdown
server.stop
server2.stop
wait_for_threads(ignore_threads)

0 comments on commit c60e5b5

Please sign in to comment.