@@ -82,6 +82,15 @@ def __call__(self) -> asyncio.Task:
8282class BaseStartupContainer (containers .DeclarativeContainer ):
8383 """Общий контейнер для старта бота."""
8484
85+ @staticmethod
86+ def get_collectors () -> list [HandlerCollector ]:
87+ from app .presentation .bot .commands .common import collector as common_collector
88+ from app .presentation .bot .commands .sample_record import (
89+ collector as sample_record_collector ,
90+ )
91+
92+ return [common_collector , sample_record_collector ]
93+
8594 redis_client = providers .Singleton (lambda : aioredis .from_url (settings .REDIS_DSN ))
8695
8796 redis_repo = providers .Factory (
@@ -116,23 +125,12 @@ class BaseStartupContainer(containers.DeclarativeContainer):
116125 answer_error_middleware ,
117126 ],
118127 callback_repo = callback_repo ,
128+ collectors = get_collectors (),
119129 )
120130
121131
122132class ApplicationStartupContainer (BaseStartupContainer ):
123- """Контейнер приложения с ленивой загрузкой collectors."""
124-
125- @staticmethod
126- def get_collectors () -> list [HandlerCollector ]:
127- from app .presentation .bot .commands .common import collector as common_collector
128- from app .presentation .bot .commands .sample_record import collector as sample_record_collector
129- return [common_collector , sample_record_collector ]
130-
131- bot = providers .Singleton (
132- Bot ,
133- collectors = providers .Callable (get_collectors ),
134- ** BaseStartupContainer .bot .kwargs ,
135- )
133+ """Main Fastapi application container."""
136134
137135 callback_task_manager = providers .Singleton (
138136 CallbackTaskManager ,
@@ -146,12 +144,6 @@ def get_collectors() -> list[HandlerCollector]:
146144
147145
148146class WorkerStartupContainer (BaseStartupContainer ):
149- """Контейнер воркера с прямым импортом collectors."""
150-
151- from app .presentation .bot .commands import common , sample_record
147+ """SAQ Worker container"""
152148
153- bot = providers .Singleton (
154- Bot ,
155- collectors = [common .collector , sample_record .collector ], # type:ignore
156- ** BaseStartupContainer .bot .kwargs ,
157- )
149+ pass
0 commit comments