aiteamutils 0.2.56__py3-none-any.whl → 0.2.58__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- aiteamutils/__init__.py +5 -0
- aiteamutils/dependencies.py +32 -1
- aiteamutils/version.py +1 -1
- {aiteamutils-0.2.56.dist-info → aiteamutils-0.2.58.dist-info}/METADATA +1 -1
- {aiteamutils-0.2.56.dist-info → aiteamutils-0.2.58.dist-info}/RECORD +6 -6
- {aiteamutils-0.2.56.dist-info → aiteamutils-0.2.58.dist-info}/WHEEL +0 -0
aiteamutils/__init__.py
CHANGED
@@ -21,6 +21,7 @@ from .base_repository import BaseRepository
|
|
21
21
|
from .validators import validate_with
|
22
22
|
from .enums import ActivityType
|
23
23
|
from .version import __version__
|
24
|
+
from .dependencies import setup_dependencies, register_service
|
24
25
|
|
25
26
|
__all__ = [
|
26
27
|
# Base Models
|
@@ -31,6 +32,10 @@ __all__ = [
|
|
31
32
|
# Database
|
32
33
|
"DatabaseService",
|
33
34
|
|
35
|
+
# Dependencies
|
36
|
+
"setup_dependencies",
|
37
|
+
"register_service",
|
38
|
+
|
34
39
|
# Exceptions
|
35
40
|
"CustomException",
|
36
41
|
"ErrorCode",
|
aiteamutils/dependencies.py
CHANGED
@@ -15,6 +15,23 @@ T = TypeVar("T", bound=BaseService)
|
|
15
15
|
R = TypeVar("R", bound=BaseRepository)
|
16
16
|
|
17
17
|
_service_registry: Dict[str, Dict[str, Any]] = {}
|
18
|
+
_session_provider = None
|
19
|
+
|
20
|
+
__all__ = [
|
21
|
+
"setup_dependencies",
|
22
|
+
"register_service",
|
23
|
+
"get_service",
|
24
|
+
"get_current_user"
|
25
|
+
]
|
26
|
+
|
27
|
+
def setup_dependencies(session_provider: Callable[[], AsyncGenerator[AsyncSession, None]]) -> None:
|
28
|
+
"""의존성 설정을 초기화합니다.
|
29
|
+
|
30
|
+
Args:
|
31
|
+
session_provider: 데이터베이스 세션을 제공하는 함수
|
32
|
+
"""
|
33
|
+
global _session_provider
|
34
|
+
_session_provider = session_provider
|
18
35
|
|
19
36
|
def register_service(
|
20
37
|
service_class: Type[T],
|
@@ -28,6 +45,13 @@ def register_service(
|
|
28
45
|
repository_class: 저장소 클래스 (선택)
|
29
46
|
**kwargs: 추가 의존성
|
30
47
|
"""
|
48
|
+
if _session_provider is None:
|
49
|
+
raise CustomException(
|
50
|
+
ErrorCode.INTERNAL_ERROR,
|
51
|
+
detail="Dependencies not initialized",
|
52
|
+
source_function="dependencies.register_service"
|
53
|
+
)
|
54
|
+
|
31
55
|
service_name = service_class.__name__
|
32
56
|
_service_registry[service_name] = {
|
33
57
|
"service_class": service_class,
|
@@ -103,9 +127,16 @@ def get_service(service_name: str) -> Callable:
|
|
103
127
|
Returns:
|
104
128
|
Callable: 서비스 의존성 함수
|
105
129
|
"""
|
130
|
+
if _session_provider is None:
|
131
|
+
raise CustomException(
|
132
|
+
ErrorCode.INTERNAL_ERROR,
|
133
|
+
detail="Dependencies not initialized",
|
134
|
+
source_function="dependencies.get_service"
|
135
|
+
)
|
136
|
+
|
106
137
|
async def _get_service_dependency(
|
107
138
|
request: Request,
|
108
|
-
session: AsyncSession
|
139
|
+
session: AsyncSession = Depends(_session_provider)
|
109
140
|
) -> BaseService:
|
110
141
|
return await _get_service(service_name, session, request)
|
111
142
|
return _get_service_dependency
|
aiteamutils/version.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
"""버전 정보"""
|
2
|
-
__version__ = "0.2.
|
2
|
+
__version__ = "0.2.58"
|
@@ -1,16 +1,16 @@
|
|
1
|
-
aiteamutils/__init__.py,sha256=
|
1
|
+
aiteamutils/__init__.py,sha256=U9UEyU0AqpLZzbPJiBvwDEh-s2405y1IeWZ0zCqFSl0,1307
|
2
2
|
aiteamutils/base_model.py,sha256=ODEnjvUVoxQ1RPCfq8-uZTfTADIA4c7Z3E6G4EVsSX0,2708
|
3
3
|
aiteamutils/base_repository.py,sha256=vqsundoN0h7FVvgqTBEnnJNMcFpvMK0s_nxBWdIYg-U,7846
|
4
4
|
aiteamutils/base_service.py,sha256=s2AcA-6_ogOQKgt2xf_3AG2s6tqBceU4nJoXO1II7S8,24588
|
5
5
|
aiteamutils/cache.py,sha256=07xBGlgAwOTAdY5mnMOQJ5EBxVwe8glVD7DkGEkxCtw,1373
|
6
6
|
aiteamutils/config.py,sha256=YdalpJb70-txhGJAS4aaKglEZAFVWgfzw5BXSWpkUz4,3232
|
7
7
|
aiteamutils/database.py,sha256=x0x5gnSyGfwo_klL9O65RnGOQID6c9tH2miwFveVyoE,6326
|
8
|
-
aiteamutils/dependencies.py,sha256=
|
8
|
+
aiteamutils/dependencies.py,sha256=UjHGgee4qKxPwHJnfMZ3YKB7m7UQNIvKNr7IdOx590c,6899
|
9
9
|
aiteamutils/enums.py,sha256=ipZi6k_QD5-3QV7Yzv7bnL0MjDz-vqfO9I5L77biMKs,632
|
10
10
|
aiteamutils/exceptions.py,sha256=_lKWXq_ujNj41xN6LDE149PwsecAP7lgYWbOBbLOntg,15368
|
11
11
|
aiteamutils/security.py,sha256=xFVrjttxwXB1TTjqgRQQgQJQohQBT28vuW8FVLjvi-M,10103
|
12
12
|
aiteamutils/validators.py,sha256=3N245cZFjgwtW_KzjESkizx5BBUDaJLbbxfNO4WOFZ0,7764
|
13
|
-
aiteamutils/version.py,sha256=
|
14
|
-
aiteamutils-0.2.
|
15
|
-
aiteamutils-0.2.
|
16
|
-
aiteamutils-0.2.
|
13
|
+
aiteamutils/version.py,sha256=57HkAV8pVrmV03eTVINw5qTQURkXwGPl2H--uJC4OWs,42
|
14
|
+
aiteamutils-0.2.58.dist-info/METADATA,sha256=yULGE3mtpwvWXzHDczGJfqu52urFzknJhm5V9PgCOGc,1718
|
15
|
+
aiteamutils-0.2.58.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
16
|
+
aiteamutils-0.2.58.dist-info/RECORD,,
|
File without changes
|