rb-commons 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rb_commons/configs/config.py +29 -12
- {rb_commons-0.1.1.dist-info → rb_commons-0.1.2.dist-info}/METADATA +1 -1
- {rb_commons-0.1.1.dist-info → rb_commons-0.1.2.dist-info}/RECORD +5 -5
- {rb_commons-0.1.1.dist-info → rb_commons-0.1.2.dist-info}/WHEEL +0 -0
- {rb_commons-0.1.1.dist-info → rb_commons-0.1.2.dist-info}/top_level.txt +0 -0
rb_commons/configs/config.py
CHANGED
@@ -1,30 +1,47 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
1
3
|
from pydantic_settings import BaseSettings
|
2
4
|
|
3
5
|
class CommonConfigs(BaseSettings):
|
4
|
-
service_name: str
|
5
|
-
service_port: int
|
6
|
-
service_id: str
|
6
|
+
service_name: str = None
|
7
|
+
service_port: int = None
|
8
|
+
service_id: str = None
|
7
9
|
service_hostname: str = '127.0.0.1'
|
8
|
-
service_host: str
|
10
|
+
service_host: str = None
|
9
11
|
|
10
12
|
consul_host: str = '127.0.0.1'
|
11
13
|
consul_port: int = 8888
|
12
14
|
|
13
15
|
# db
|
14
|
-
POSTGRES_HOST: str
|
15
|
-
POSTGRES_USER: str
|
16
|
-
POSTGRES_PORT: int
|
17
|
-
POSTGRES_PASSWORD: str
|
18
|
-
POSTGRES_DB: str
|
19
|
-
DB_ALEMBIC_URL: str
|
16
|
+
POSTGRES_HOST: str = None
|
17
|
+
POSTGRES_USER: str = None
|
18
|
+
POSTGRES_PORT: int = None
|
19
|
+
POSTGRES_PASSWORD: str = None
|
20
|
+
POSTGRES_DB: str = None
|
21
|
+
DB_ALEMBIC_URL: str = None
|
20
22
|
|
21
23
|
@property
|
22
|
-
def database_url(self):
|
23
|
-
|
24
|
+
def database_url(self) -> Optional[str]:
|
25
|
+
"""Construct the database URL if all required fields are present."""
|
26
|
+
required_fields = [
|
27
|
+
self.POSTGRES_USER,
|
28
|
+
self.POSTGRES_PASSWORD,
|
29
|
+
self.POSTGRES_HOST,
|
30
|
+
self.POSTGRES_PORT,
|
31
|
+
self.POSTGRES_DB
|
32
|
+
]
|
33
|
+
if all(required_fields):
|
34
|
+
return (
|
35
|
+
f"postgresql+asyncpg://{self.POSTGRES_USER}:"
|
36
|
+
f"{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:"
|
37
|
+
f"{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
|
38
|
+
)
|
39
|
+
return None
|
24
40
|
|
25
41
|
class Config:
|
26
42
|
env_file = ".env"
|
27
43
|
env_file_encoding = "utf-8"
|
44
|
+
extra = "ignore"
|
28
45
|
|
29
46
|
|
30
47
|
configs = CommonConfigs()
|
@@ -1,10 +1,10 @@
|
|
1
1
|
rb_commons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
rb_commons/configs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
-
rb_commons/configs/config.py,sha256=
|
3
|
+
rb_commons/configs/config.py,sha256=2i5DPn-JmlDpQvIkfJ3Ck5BoWNqz0qqRjK9qE6PkuWw,1309
|
4
4
|
rb_commons/orm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
rb_commons/orm/exceptions.py,sha256=1aMctiEwrPjyehoXVX1l6ML5ZOhmDkmBISzlTD5ey1Y,509
|
6
6
|
rb_commons/orm/managers.py,sha256=VopUw29sCXrPTriBALR9qwkG5yCu6BDHRgR7cCygNiE,6726
|
7
|
-
rb_commons-0.1.
|
8
|
-
rb_commons-0.1.
|
9
|
-
rb_commons-0.1.
|
10
|
-
rb_commons-0.1.
|
7
|
+
rb_commons-0.1.2.dist-info/METADATA,sha256=LTZcAZ4Ouxoai-9o9xY1y8fU_qZpMu_P3QDMG_nI-bY,6276
|
8
|
+
rb_commons-0.1.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
9
|
+
rb_commons-0.1.2.dist-info/top_level.txt,sha256=HPx_WAYo3_fbg1WCeGHsz3wPGio1ucbnrlm2lmqlJog,11
|
10
|
+
rb_commons-0.1.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|