Skip to content

Commit

Permalink
feat: add in-database configuration for pool settings
Browse files Browse the repository at this point in the history
  • Loading branch information
laurenceisla committed Dec 28, 2023
1 parent b2095a8 commit 363cc68
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
4 changes: 4 additions & 0 deletions src/PostgREST/Config/Database.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ dbSettingsNames =
,"db_pre_config"
,"db_extra_search_path"
,"db_max_rows"
,"db_pool"
,"db_pool_acquisition_timeout"
,"db_pool_max_idletime"
,"db_pool_max_lifetime"
,"db_plan_enabled"
,"db_pre_request"
,"db_prepared_statements"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ db-channel-enabled = false
db-extra-search-path = "public,extensions,other"
db-max-rows = 100
db-plan-enabled = true
db-pool = 1
db-pool-acquisition-timeout = 30
db-pool-max-lifetime = 3600
db-pool-max-idletime = 60
db-pool = 3
db-pool-acquisition-timeout = 20
db-pool-max-lifetime = 360
db-pool-max-idletime = 20
db-pool-automatic-recovery = false
db-pre-request = "test.other_custom_headers"
db-prepared-statements = false
Expand Down
8 changes: 4 additions & 4 deletions test/io/configs/expected/no-defaults-with-db.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ db-channel-enabled = false
db-extra-search-path = "public,extensions,private"
db-max-rows = 1000
db-plan-enabled = true
db-pool = 1
db-pool-acquisition-timeout = 30
db-pool-max-lifetime = 3600
db-pool-max-idletime = 60
db-pool = 2
db-pool-acquisition-timeout = 15
db-pool-max-lifetime = 180
db-pool-max-idletime = 10
db-pool-automatic-recovery = false
db-pre-request = "test.custom_headers"
db-prepared-statements = false
Expand Down
12 changes: 8 additions & 4 deletions test/io/db_config.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ ALTER ROLE db_config_authenticator SET pgrst.db_prepared_statements = 'false';
ALTER ROLE db_config_authenticator SET pgrst.db_pre_request = 'test.custom_headers';
ALTER ROLE db_config_authenticator SET pgrst.db_max_rows = '1000';
ALTER ROLE db_config_authenticator SET pgrst.db_extra_search_path = 'public, extensions';
ALTER ROLE db_config_authenticator SET pgrst.db_pool = '2';
ALTER ROLE db_config_authenticator SET pgrst.db_pool_acquisition_timeout = '15';
ALTER ROLE db_config_authenticator SET pgrst.db_pool_max_lifetime = '180';
ALTER ROLE db_config_authenticator SET pgrst.db_pool_max_idletime = '10';
ALTER ROLE db_config_authenticator SET pgrst.not_existing = 'should be ignored';
ALTER ROLE db_config_authenticator SET pgrst.server_cors_allowed_origins = 'http://example.com';
ALTER ROLE db_config_authenticator SET pgrst.server_trace_header = 'CF-Ray';
Expand All @@ -42,11 +46,7 @@ ALTER ROLE db_config_authenticator SET pgrst.log_level = 'ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_uri = 'postgresql://ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_channel_enabled = 'ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_channel = 'ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_pool = 'ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_pool_timeout = 'ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_pool_acquisition_timeout = 'ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_pool_max_lifetime = 'ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_pool_max_idletime = 'ignored';
ALTER ROLE db_config_authenticator SET pgrst.db_config = 'true';

-- other authenticator reloadable config options
Expand All @@ -64,6 +64,10 @@ ALTER ROLE other_authenticator SET pgrst.db_prepared_statements = 'false';
ALTER ROLE other_authenticator SET pgrst.db_pre_request = 'test.other_custom_headers';
ALTER ROLE other_authenticator SET pgrst.db_max_rows = '100';
ALTER ROLE other_authenticator SET pgrst.db_extra_search_path = 'public, extensions, other';
ALTER ROLE other_authenticator SET pgrst.db_pool = '3';
ALTER ROLE other_authenticator SET pgrst.db_pool_acquisition_timeout = '20';
ALTER ROLE other_authenticator SET pgrst.db_pool_max_lifetime = '360';
ALTER ROLE other_authenticator SET pgrst.db_pool_max_idletime = '20';
ALTER ROLE other_authenticator SET pgrst.openapi_mode = 'disabled';
ALTER ROLE other_authenticator SET pgrst.openapi_security_active = 'false';
ALTER ROLE other_authenticator SET pgrst.server_cors_allowed_origins = 'http://example.com';
Expand Down

0 comments on commit 363cc68

Please sign in to comment.