agreg-server/server/app/dependencies.py

23 lines
563 B
Python
Raw Normal View History

2026-05-10 12:36:38 +02:00
import os
from functools import lru_cache
from adapters.postgres import connect
from adapters.postgres_query import PgReadingQueryRepository
from services.consumption_service import ConsumptionService
@lru_cache
def get_conn():
return connect(os.getenv("DATABASE_URL", "postgresql://simugaz:simugaz@db/simugaz"))
## Repositories
def get_query_repo() -> PgReadingQueryRepository:
return PgReadingQueryRepository(get_conn())
## Services
def get_consumption_service() -> ConsumptionService:
return ConsumptionService(get_query_repo())
## Adapters