aiteamutils 0.2.46__tar.gz → 0.2.48__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/PKG-INFO +1 -1
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/database.py +23 -21
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/dependencies.py +5 -2
- aiteamutils-0.2.48/aiteamutils/version.py +2 -0
- aiteamutils-0.2.46/aiteamutils/version.py +0 -2
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/.cursorrules +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/.gitignore +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/README.md +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/__init__.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/base_repository.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/base_service.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/config.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/exceptions.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/aiteamutils/validators.py +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/pyproject.toml +0 -0
- {aiteamutils-0.2.46 → aiteamutils-0.2.48}/setup.py +0 -0
@@ -1021,27 +1021,30 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
1021
1021
|
)
|
1022
1022
|
|
1023
1023
|
try:
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1024
|
+
session = db_service.get_session()
|
1025
|
+
if session is None:
|
1026
|
+
raise CustomException(
|
1027
|
+
ErrorCode.DB_CONNECTION_ERROR,
|
1028
|
+
detail="Failed to create database session",
|
1029
|
+
source_function="get_db"
|
1030
|
+
)
|
1031
|
+
|
1032
|
+
# 세션이 유효한지 확인
|
1033
|
+
try:
|
1034
|
+
await session.execute(select(1))
|
1035
|
+
except Exception as e:
|
1036
|
+
await session.close()
|
1037
|
+
raise CustomException(
|
1038
|
+
ErrorCode.DB_CONNECTION_ERROR,
|
1039
|
+
detail="Database session is not valid",
|
1040
|
+
source_function="get_db",
|
1041
|
+
original_error=e
|
1042
|
+
)
|
1031
1043
|
|
1032
|
-
|
1033
|
-
try:
|
1034
|
-
await session.execute(select(1))
|
1035
|
-
except Exception as e:
|
1036
|
-
raise CustomException(
|
1037
|
-
ErrorCode.DB_CONNECTION_ERROR,
|
1038
|
-
detail="Database session is not valid",
|
1039
|
-
source_function="get_db",
|
1040
|
-
original_error=e
|
1041
|
-
)
|
1042
|
-
|
1043
|
-
yield session
|
1044
|
+
yield session
|
1044
1045
|
except Exception as e:
|
1046
|
+
if isinstance(e, CustomException):
|
1047
|
+
raise e
|
1045
1048
|
raise CustomException(
|
1046
1049
|
ErrorCode.DB_CONNECTION_ERROR,
|
1047
1050
|
detail=f"Failed to get database session: {str(e)}",
|
@@ -1049,8 +1052,7 @@ async def get_db() -> AsyncGenerator[AsyncSession, None]:
|
|
1049
1052
|
original_error=e
|
1050
1053
|
)
|
1051
1054
|
finally:
|
1052
|
-
|
1053
|
-
await session.close()
|
1055
|
+
await session.close()
|
1054
1056
|
|
1055
1057
|
async def get_database_service() -> DatabaseService:
|
1056
1058
|
"""DatabaseService 의존성
|
@@ -5,7 +5,7 @@ from jose import JWTError, jwt
|
|
5
5
|
from sqlalchemy.ext.asyncio import AsyncSession
|
6
6
|
import logging
|
7
7
|
|
8
|
-
from .database import DatabaseServiceManager, get_db, get_database_service
|
8
|
+
from .database import DatabaseServiceManager, DatabaseService, get_db, get_database_service
|
9
9
|
from .exceptions import CustomException, ErrorCode
|
10
10
|
from .config import get_settings
|
11
11
|
|
@@ -56,7 +56,10 @@ def get_service(name: str):
|
|
56
56
|
Returns:
|
57
57
|
Callable: 서비스 인스턴스를 반환하는 의존성 함수
|
58
58
|
"""
|
59
|
-
|
59
|
+
def _get_service(
|
60
|
+
db_service: DatabaseService = Depends(get_database_service),
|
61
|
+
session: AsyncSession = Depends(get_db)
|
62
|
+
):
|
60
63
|
try:
|
61
64
|
repository_class, service_class = service_registry.get(name)
|
62
65
|
repository = repository_class(db_service)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|