mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Expose config values for database connection pool
This commit is contained in:
parent
82e6f6e095
commit
d0480f5381
2 changed files with 41 additions and 0 deletions
|
@ -15,6 +15,29 @@ db:
|
|||
port: 5432
|
||||
dbname: invidious
|
||||
|
||||
##
|
||||
## Granular pooling behavior controls
|
||||
## The following is entirely optional.
|
||||
##
|
||||
|
||||
## Initial amount of connections in the pool
|
||||
#initial_pool_size:
|
||||
|
||||
## Maximum amount of connections in the pool. 0 is unlimited.
|
||||
#max_pool_size: 0
|
||||
|
||||
## Amount of connections when idle
|
||||
#max_idle_pool_size: 1
|
||||
|
||||
## Amount of seconds to wait if the connection pool is full, and a connection is unavailable.
|
||||
#checkout_timeout: 5
|
||||
|
||||
## Amount of retries when a connection is either lost or can't be established.
|
||||
#retry_attempts: 1
|
||||
|
||||
## Amount of seconds between each retry
|
||||
#retry_delay: 1
|
||||
|
||||
##
|
||||
## Database configuration using a single URI. This is an
|
||||
## alternative to the 'db' parameter above. If both forms
|
||||
|
|
|
@ -188,6 +188,16 @@ class Config
|
|||
host: db.host,
|
||||
port: db.port,
|
||||
path: db.dbname,
|
||||
|
||||
# Pooling config
|
||||
query: URI::Params.build do |pool_controls|
|
||||
pool_controls.add "initial_pool_size", db.initial_pool_size.to_s
|
||||
pool_controls.add "max_pool_size", db.max_pool_size.to_s
|
||||
pool_controls.add "max_idle_pool_size", db.max_idle_pool_size.to_s
|
||||
pool_controls.add "checkout_timeout", db.checkout_timeout.to_s
|
||||
pool_controls.add "retry_attempts", db.retry_attempts.to_s
|
||||
pool_controls.add "retry_delay", db.retry_delay.to_s
|
||||
end
|
||||
)
|
||||
else
|
||||
puts "Config : Either database_url or db.* is required"
|
||||
|
@ -207,6 +217,14 @@ struct DBConfig
|
|||
property host : String
|
||||
property port : Int32
|
||||
property dbname : String
|
||||
|
||||
# https://crystal-lang.org/reference/database/connection_pool.html#configuration
|
||||
property initial_pool_size : Int32 = 1
|
||||
property max_pool_size : Int32 = 0
|
||||
property max_idle_pool_size : Int32 = 1
|
||||
property checkout_timeout : Int32 = 5
|
||||
property retry_attempts : Int32 = 1
|
||||
property retry_delay : Int32 = 1
|
||||
end
|
||||
|
||||
def login_req(f_req)
|
||||
|
|
Loading…
Reference in a new issue