Skip to content

Commit 130b8ae

Browse files
committed
🔧(backend) enable psycopg-pool allowing configuring min and max size
We enable the pool option on the DB configuration. We want to allow the configuration of the min and max sixe in a first time. They can be configured using the settings DB_PSYCOPG_POOL_MIN_SIZE and DB_PSYCOPG_POOL_MAX_SIZE. They have their default value to 4 and None.
1 parent d18bf0b commit 130b8ae

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docs/env.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ These are the environment variables you can set for the `impress-backend` contai
4646
| DB_NAME | Name of the database | impress |
4747
| DB_PASSWORD | Password to authenticate with | pass |
4848
| DB_PORT | Port of the database | 5432 |
49+
| DB_PSYCOPG_POOL_MIN_SIZE | The psycopg min pool size | 4 |
50+
| DB_PSYCOPG_POOL_MAX_SIZE | The psycopg max pool size | None |
4951
| DB_USER | User to authenticate with | dinum |
5052
| DJANGO_ALLOWED_HOSTS | Allowed hosts | [] |
5153
| DJANGO_CELERY_BROKER_TRANSPORT_OPTIONS | Celery broker transport options | {} |

src/backend/impress/settings.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,19 @@ class Base(Configuration):
9999
"localhost", environ_name="DB_HOST", environ_prefix=None
100100
),
101101
"PORT": values.Value(5432, environ_name="DB_PORT", environ_prefix=None),
102+
"OPTIONS": {
103+
# https://www.psycopg.org/psycopg3/docs/api/pool.html#psycopg_pool.ConnectionPool
104+
"pool": {
105+
"min_size": values.IntegerValue(
106+
4, environ_name="DB_PSYCOPG_POOL_MIN_SIZE", environ_prefix=None
107+
),
108+
"max_size": values.IntegerValue(
109+
None,
110+
environ_name="DB_PSYCOPG_POOL_MAX_SIZE",
111+
environ_prefix=None,
112+
),
113+
}
114+
},
102115
}
103116
}
104117
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

0 commit comments

Comments
 (0)