mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Make DB::Pool accept a block
This commit is contained in:
parent
fff67e86a0
commit
1cce4685ff
3 changed files with 12 additions and 12 deletions
|
@ -29,7 +29,7 @@ module DB
|
|||
pool_options = @driver.connection_pool_options(params)
|
||||
|
||||
@pool = uninitialized Pool(Connection) # in order to use self in the factory proc
|
||||
@pool = Pool.new(->{ @driver.build_connection(self).as(Connection) }, **pool_options)
|
||||
@pool = Pool.new(**pool_options) { @driver.build_connection(self).as(Connection) }
|
||||
end
|
||||
|
||||
# Closes all connection to the database.
|
||||
|
|
|
@ -7,7 +7,7 @@ module DB
|
|||
@total = [] of T
|
||||
@checkout_timeout : Float64
|
||||
|
||||
def initialize(@factory : Proc(T), @initial_pool_size = 1, @max_pool_size = 1, @max_idle_pool_size = 1, @checkout_timeout = 5.0)
|
||||
def initialize(@initial_pool_size = 1, @max_pool_size = 1, @max_idle_pool_size = 1, @checkout_timeout = 5.0, &@factory : -> T)
|
||||
@initial_pool_size.times { build_resource }
|
||||
|
||||
@availability_channel = Channel(Nil).new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue