mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
allow DB to use a connection pool.
allow Driver to parse connection pool options for extensibility. fix waiting_resource counter after a timeout was generated.
This commit is contained in:
parent
b8cabee956
commit
a2c22c16cf
7 changed files with 46 additions and 22 deletions
|
@ -61,7 +61,7 @@ describe DB do
|
|||
it "should raise if the sole connection is been used" do
|
||||
with_dummy do |db|
|
||||
db.query "1" do |rs|
|
||||
expect_raises Exception, /DB Pool Exhausted/ do
|
||||
expect_raises DB::PoolTimeout do
|
||||
db.scalar "2"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -187,7 +187,7 @@ end
|
|||
def with_dummy
|
||||
DummyDriver::DummyConnection.clear_connections
|
||||
|
||||
DB.open "dummy://host" do |db|
|
||||
DB.open "dummy://host?checkout_timeout=0.5" do |db|
|
||||
yield db
|
||||
end
|
||||
end
|
||||
|
|
|
@ -131,6 +131,13 @@ describe DB::Pool do
|
|||
end
|
||||
end
|
||||
|
||||
it "should be able to release after a timeout" do
|
||||
pool = DB::Pool.new(->{ Closable.new }, max_pool_size: 1, checkout_timeout: 0.1)
|
||||
a = pool.checkout
|
||||
pool.checkout rescue nil
|
||||
pool.release a
|
||||
end
|
||||
|
||||
it "should close if max idle amount is reached" do
|
||||
all = [] of Closable
|
||||
pool = DB::Pool.new(->{ Closable.new.tap { |c| all << c } }, max_pool_size: 3, max_idle_pool_size: 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue