aiteamutils 0.2.15__tar.gz → 0.2.16__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/PKG-INFO +1 -1
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/__init__.py +9 -1
- aiteamutils-0.2.16/aiteamutils/config.py +59 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/database.py +33 -1
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/dependencies.py +2 -58
- aiteamutils-0.2.16/aiteamutils/version.py +2 -0
- aiteamutils-0.2.15/aiteamutils/config.py +0 -26
- aiteamutils-0.2.15/aiteamutils/version.py +0 -2
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/.gitignore +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/README.md +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/base_model.py +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/base_repository.py +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/base_service.py +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/cache.py +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/enums.py +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/exceptions.py +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/security.py +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/aiteamutils/validators.py +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/pyproject.toml +0 -0
- {aiteamutils-0.2.15 → aiteamutils-0.2.16}/setup.py +0 -0
@@ -1,5 +1,10 @@
|
|
1
1
|
from .base_model import Base
|
2
|
-
from .database import
|
2
|
+
from .database import (
|
3
|
+
DatabaseService,
|
4
|
+
get_db,
|
5
|
+
get_database_service,
|
6
|
+
get_database_session
|
7
|
+
)
|
3
8
|
from .exceptions import (
|
4
9
|
CustomException,
|
5
10
|
ErrorCode,
|
@@ -30,6 +35,9 @@ __all__ = [
|
|
30
35
|
|
31
36
|
# Database
|
32
37
|
"DatabaseService",
|
38
|
+
"get_db",
|
39
|
+
"get_database_service",
|
40
|
+
"get_database_session",
|
33
41
|
|
34
42
|
# Exceptions
|
35
43
|
"CustomException",
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"""설정 모듈."""
|
2
|
+
from typing import Union
|
3
|
+
from .database import init_database_service
|
4
|
+
|
5
|
+
class Settings:
|
6
|
+
"""기본 설정 클래스"""
|
7
|
+
def __init__(self, jwt_secret: str, jwt_algorithm: str = "HS256"):
|
8
|
+
self.JWT_SECRET = jwt_secret
|
9
|
+
self.JWT_ALGORITHM = jwt_algorithm
|
10
|
+
|
11
|
+
_settings: Union[Settings, None] = None
|
12
|
+
|
13
|
+
def init_settings(
|
14
|
+
jwt_secret: str,
|
15
|
+
jwt_algorithm: str = "HS256",
|
16
|
+
db_url: str = None,
|
17
|
+
db_echo: bool = False,
|
18
|
+
db_pool_size: int = 5,
|
19
|
+
db_max_overflow: int = 10,
|
20
|
+
db_pool_timeout: int = 30,
|
21
|
+
db_pool_recycle: int = 1800
|
22
|
+
):
|
23
|
+
"""설정 초기화 함수
|
24
|
+
|
25
|
+
Args:
|
26
|
+
jwt_secret (str): JWT 시크릿 키
|
27
|
+
jwt_algorithm (str, optional): JWT 알고리즘. Defaults to "HS256".
|
28
|
+
db_url (str, optional): 데이터베이스 URL
|
29
|
+
db_echo (bool, optional): SQL 로깅 여부
|
30
|
+
db_pool_size (int, optional): DB 커넥션 풀 크기
|
31
|
+
db_max_overflow (int, optional): 최대 초과 커넥션 수
|
32
|
+
db_pool_timeout (int, optional): 커넥션 풀 타임아웃
|
33
|
+
db_pool_recycle (int, optional): 커넥션 재활용 시간
|
34
|
+
"""
|
35
|
+
global _settings
|
36
|
+
_settings = Settings(jwt_secret, jwt_algorithm)
|
37
|
+
|
38
|
+
if db_url:
|
39
|
+
init_database_service(
|
40
|
+
db_url=db_url,
|
41
|
+
db_echo=db_echo,
|
42
|
+
db_pool_size=db_pool_size,
|
43
|
+
db_max_overflow=db_max_overflow,
|
44
|
+
db_pool_timeout=db_pool_timeout,
|
45
|
+
db_pool_recycle=db_pool_recycle
|
46
|
+
)
|
47
|
+
|
48
|
+
def get_settings() -> Settings:
|
49
|
+
"""현재 설정을 반환하는 함수
|
50
|
+
|
51
|
+
Returns:
|
52
|
+
Settings: 설정 객체
|
53
|
+
|
54
|
+
Raises:
|
55
|
+
RuntimeError: 설정이 초기화되지 않은 경우
|
56
|
+
"""
|
57
|
+
if _settings is None:
|
58
|
+
raise RuntimeError("Settings not initialized. Call init_settings first.")
|
59
|
+
return _settings
|
@@ -880,4 +880,36 @@ class DatabaseService:
|
|
880
880
|
detail=str(e),
|
881
881
|
source_function="DatabaseService.refresh",
|
882
882
|
original_error=e
|
883
|
-
)
|
883
|
+
)
|
884
|
+
|
885
|
+
def init_database_service(
|
886
|
+
db_url: str,
|
887
|
+
db_echo: bool = False,
|
888
|
+
db_pool_size: int = 5,
|
889
|
+
db_max_overflow: int = 10,
|
890
|
+
db_pool_timeout: int = 30,
|
891
|
+
db_pool_recycle: int = 1800
|
892
|
+
) -> DatabaseService:
|
893
|
+
"""데이터베이스 서비스를 초기화합니다.
|
894
|
+
|
895
|
+
Args:
|
896
|
+
db_url (str): 데이터베이스 URL
|
897
|
+
db_echo (bool, optional): SQL 로깅 여부
|
898
|
+
db_pool_size (int, optional): DB 커넥션 풀 크기
|
899
|
+
db_max_overflow (int, optional): 최대 초과 커넥션 수
|
900
|
+
db_pool_timeout (int, optional): 커넥션 풀 타임아웃
|
901
|
+
db_pool_recycle (int, optional): 커넥션 재활용 시간
|
902
|
+
|
903
|
+
Returns:
|
904
|
+
DatabaseService: 초기화된 데이터베이스 서비스 인스턴스
|
905
|
+
"""
|
906
|
+
global _database_service
|
907
|
+
_database_service = DatabaseService(
|
908
|
+
db_url=db_url,
|
909
|
+
db_echo=db_echo,
|
910
|
+
db_pool_size=db_pool_size,
|
911
|
+
db_max_overflow=db_max_overflow,
|
912
|
+
db_pool_timeout=db_pool_timeout,
|
913
|
+
db_pool_recycle=db_pool_recycle
|
914
|
+
)
|
915
|
+
return _database_service
|
@@ -1,67 +1,11 @@
|
|
1
|
-
from typing import Type, Dict, Tuple, Any, Callable
|
1
|
+
from typing import Type, Dict, Tuple, Any, Callable
|
2
2
|
from fastapi import Depends, status
|
3
3
|
from fastapi.security import OAuth2PasswordBearer
|
4
4
|
from jose import JWTError, jwt
|
5
5
|
|
6
6
|
from .database import DatabaseService, get_database_service
|
7
7
|
from .exceptions import CustomException, ErrorCode
|
8
|
-
|
9
|
-
class Settings:
|
10
|
-
"""기본 설정 클래스"""
|
11
|
-
def __init__(self, jwt_secret: str, jwt_algorithm: str = "HS256"):
|
12
|
-
self.JWT_SECRET = jwt_secret
|
13
|
-
self.JWT_ALGORITHM = jwt_algorithm
|
14
|
-
|
15
|
-
_settings: Union[Settings, None] = None
|
16
|
-
|
17
|
-
def init_settings(
|
18
|
-
jwt_secret: str,
|
19
|
-
jwt_algorithm: str = "HS256",
|
20
|
-
db_url: str = None,
|
21
|
-
db_echo: bool = False,
|
22
|
-
db_pool_size: int = 5,
|
23
|
-
db_max_overflow: int = 10,
|
24
|
-
db_pool_timeout: int = 30,
|
25
|
-
db_pool_recycle: int = 1800
|
26
|
-
):
|
27
|
-
"""설정 초기화 함수
|
28
|
-
|
29
|
-
Args:
|
30
|
-
jwt_secret (str): JWT 시크릿 키
|
31
|
-
jwt_algorithm (str, optional): JWT 알고리즘. Defaults to "HS256".
|
32
|
-
db_url (str, optional): 데이터베이스 URL
|
33
|
-
db_echo (bool, optional): SQL 로깅 여부
|
34
|
-
db_pool_size (int, optional): DB 커넥션 풀 크기
|
35
|
-
db_max_overflow (int, optional): 최대 초과 커넥션 수
|
36
|
-
db_pool_timeout (int, optional): 커넥션 풀 타임아웃
|
37
|
-
db_pool_recycle (int, optional): 커넥션 재활용 시간
|
38
|
-
"""
|
39
|
-
global _settings
|
40
|
-
_settings = Settings(jwt_secret, jwt_algorithm)
|
41
|
-
|
42
|
-
if db_url:
|
43
|
-
from .database import _database_service
|
44
|
-
_database_service = DatabaseService(
|
45
|
-
db_url=db_url,
|
46
|
-
db_echo=db_echo,
|
47
|
-
db_pool_size=db_pool_size,
|
48
|
-
db_max_overflow=db_max_overflow,
|
49
|
-
db_pool_timeout=db_pool_timeout,
|
50
|
-
db_pool_recycle=db_pool_recycle
|
51
|
-
)
|
52
|
-
|
53
|
-
def get_settings() -> Settings:
|
54
|
-
"""현재 설정을 반환하는 함수
|
55
|
-
|
56
|
-
Returns:
|
57
|
-
Settings: 설정 객체
|
58
|
-
|
59
|
-
Raises:
|
60
|
-
RuntimeError: 설정이 초기화되지 않은 경우
|
61
|
-
"""
|
62
|
-
if _settings is None:
|
63
|
-
raise RuntimeError("Settings not initialized. Call init_settings first.")
|
64
|
-
return _settings
|
8
|
+
from .config import get_settings
|
65
9
|
|
66
10
|
class ServiceRegistry:
|
67
11
|
"""서비스 레지스트리를 관리하는 클래스"""
|
@@ -1,26 +0,0 @@
|
|
1
|
-
"""설정 모듈."""
|
2
|
-
from typing import Optional
|
3
|
-
from pydantic_settings import BaseSettings
|
4
|
-
|
5
|
-
class Settings(BaseSettings):
|
6
|
-
"""애플리케이션 설정."""
|
7
|
-
|
8
|
-
# 데이터베이스 설정
|
9
|
-
DB_ECHO: bool = False
|
10
|
-
DB_POOL_SIZE: int = 5
|
11
|
-
DB_MAX_OVERFLOW: int = 10
|
12
|
-
DB_POOL_TIMEOUT: int = 30
|
13
|
-
DB_POOL_RECYCLE: int = 1800
|
14
|
-
|
15
|
-
# JWT 설정
|
16
|
-
JWT_SECRET: str = "your-secret-key"
|
17
|
-
JWT_ALGORITHM: str = "HS256"
|
18
|
-
ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
|
19
|
-
TOKEN_ISSUER: str = "ai-team-platform"
|
20
|
-
TOKEN_AUDIENCE: str = "ai-team-users"
|
21
|
-
|
22
|
-
class Config:
|
23
|
-
env_file = ".env"
|
24
|
-
case_sensitive = True
|
25
|
-
|
26
|
-
settings = Settings()
|
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
|