11from pathlib import Path
22from pydantic_settings import BaseSettings , SettingsConfigDict
3- from pydantic import BaseModel
3+ from pydantic import BaseModel , ConfigDict
44from starlette .config import Config
5+ from celery .schedules import crontab
56
67
78base_dir = Path (__file__ ).resolve ().parent .parent
1112config = Config ('.env' )
1213
1314
15+ class AlembicSettings (BaseModel ):
16+ """
17+ Настройки Alembic
18+ """
19+ CONFIG_PATH : Path = Path ('alembic.ini' )
20+ MIGRATION_PATH : Path = Path ('async_alembic/' )
21+
22+
1423class TestDBSettings (BaseModel ):
1524 """
1625 Настройки тестовой базы данных
@@ -35,6 +44,23 @@ class DBSettings(BaseModel):
3544 url : str = f'{ _engine } ://{ _owner } :{ _password } @{ _name } /{ _db_name } '
3645
3746
47+ class CelerySettings (BaseModel ):
48+ """
49+ Настройки Celery
50+ """
51+ model_config = ConfigDict (
52+ arbitrary_types_allowed = True ,
53+ )
54+ TIMEZONE : str = 'Europe/Moscow'
55+ TIMEDELTA_PER_DAY : crontab = crontab (minute = 0 ,
56+ hour = 2 ,
57+ day_of_week = '*/1' ,
58+ day_of_month = '*/1' ,
59+ month_of_year = '*/1' ,
60+ )
61+ TEST_TIMEDELTA : crontab = crontab (minute = '*/1' )
62+
63+
3864class RabbitSettings (BaseModel ):
3965 """
4066 Настройки RabbitMQ
@@ -62,7 +88,9 @@ class Settings(BaseSettings):
6288 )
6389 db : DBSettings = DBSettings ()
6490 test_db : TestDBSettings = TestDBSettings ()
91+ celery : CelerySettings = CelerySettings ()
6592 rabbit : RabbitSettings = RabbitSettings ()
93+ alembic : AlembicSettings = AlembicSettings ()
6694 debug : bool = bool (int (config ('DEBUG' )))
6795 API_PREFIX : str = '/api/v1'
6896 BASE_DIR : Path = base_dir
0 commit comments