This commit is contained in:
2025-12-23 22:20:42 +03:00
parent 71e8d1079e
commit 493c385cb1
31 changed files with 574 additions and 507 deletions
+3 -4
View File
@@ -1,7 +1,7 @@
from dishka import Container, Provider, Scope, provide
from fastapi import Request
from sqlalchemy.ext.asyncio import AsyncSession
from contextlib import asynccontextmanager
from collections.abc import AsyncIterator
from src.infrastructure.database.base import AsyncSessionLocal
from src.infrastructure.repositories.postgresql.user_repository import PostgreSQLUserRepository
@@ -39,8 +39,7 @@ from src.application.use_cases.rag_use_cases import RAGUseCases
class DatabaseProvider(Provider):
@provide(scope=Scope.REQUEST)
@asynccontextmanager
async def get_db(self) -> AsyncSession:
async def get_db(self) -> AsyncIterator[AsyncSession]:
async with AsyncSessionLocal() as session:
try:
yield session
@@ -77,7 +76,7 @@ class RepositoryProvider(Provider):
class ServiceProvider(Provider):
@provide(scope=Scope.APP)
def get_redis_client(self) -> RedisClient:
return RedisClient()
return RedisClient(host=settings.REDIS_HOST, port=settings.REDIS_PORT)
@provide(scope=Scope.APP)
def get_cache_service(self, redis_client: RedisClient) -> CacheService: