Add connection retry logic to connection pool

This commit is contained in:
Brian J. Cardiff 2016-08-31 17:32:01 -03:00
parent dbf7c94ef4
commit 47e7d826e8
8 changed files with 102 additions and 9 deletions

View file

@ -63,4 +63,28 @@ describe DB::Database do
end
stmt.closed?.should be_true
end
it "should not reconnect if connection is lost and retry_attempts=0" do
DummyDriver::DummyConnection.clear_connections
DB.open "dummy://localhost:1027?initial_pool_size=1&max_pool_size=1&retry_attempts=0" do |db|
db.exec("stmt1")
DummyDriver::DummyConnection.connections.size.should eq(1)
DummyDriver::DummyConnection.connections.first.disconnect!
expect_raises DB::PoolRetryAttemptsExceeded do
db.exec("stmt1")
end
DummyDriver::DummyConnection.connections.size.should eq(1)
end
end
it "should reconnect if connection is lost and executing same statement" do
DummyDriver::DummyConnection.clear_connections
DB.open "dummy://localhost:1027?initial_pool_size=1&max_pool_size=1&retry_attempts=1" do |db|
db.exec("stmt1")
DummyDriver::DummyConnection.connections.size.should eq(1)
DummyDriver::DummyConnection.connections.first.disconnect!
db.exec("stmt1")
DummyDriver::DummyConnection.connections.size.should eq(2)
end
end
end