mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
default max_pool_size to 0 = unlimited
This commit is contained in:
parent
79ec638de4
commit
cd10dabba2
6 changed files with 19 additions and 7 deletions
|
@ -7,7 +7,7 @@ module DB
|
|||
# The connection pool can be configured from URI parameters:
|
||||
#
|
||||
# - initial_pool_size (default 1)
|
||||
# - max_pool_size (default 1)
|
||||
# - max_pool_size (default 0 = unlimited)
|
||||
# - max_idle_pool_size (default 1)
|
||||
# - checkout_timeout (default 5.0)
|
||||
# - retry_attempts (default 1)
|
||||
|
|
|
@ -31,7 +31,7 @@ module DB
|
|||
def connection_pool_options(params : HTTP::Params)
|
||||
{
|
||||
initial_pool_size: params.fetch("initial_pool_size", 1).to_i,
|
||||
max_pool_size: params.fetch("max_pool_size", 1).to_i,
|
||||
max_pool_size: params.fetch("max_pool_size", 0).to_i,
|
||||
max_idle_pool_size: params.fetch("max_idle_pool_size", 1).to_i,
|
||||
checkout_timeout: params.fetch("checkout_timeout", 5.0).to_f,
|
||||
retry_attempts: params.fetch("retry_attempts", 1).to_i,
|
||||
|
|
|
@ -12,7 +12,7 @@ module DB
|
|||
@retry_attempts : Int32
|
||||
@retry_delay : Float64
|
||||
|
||||
def initialize(@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 = 0, @max_idle_pool_size = 1, @checkout_timeout = 5.0,
|
||||
@retry_attempts = 1, @retry_delay = 0.2, &@factory : -> T)
|
||||
@initial_pool_size.times { build_resource }
|
||||
|
||||
|
@ -124,7 +124,7 @@ module DB
|
|||
end
|
||||
|
||||
private def can_increase_pool
|
||||
@total.size < @max_pool_size
|
||||
@max_pool_size == 0 || @total.size < @max_pool_size
|
||||
end
|
||||
|
||||
private def can_increase_idle_pool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue