aiteamutils 0.2.14__tar.gz → 0.2.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.14
3
+ Version: 0.2.16
4
4
  Summary: AI Team Utilities
5
5
  Project-URL: Homepage, https://github.com/yourusername/aiteamutils
6
6
  Project-URL: Issues, https://github.com/yourusername/aiteamutils/issues
@@ -1,5 +1,10 @@
1
1
  from .base_model import Base
2
- from .database import DatabaseService
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
@@ -17,7 +17,7 @@ from .enums import ActivityType
17
17
  T = TypeVar("T", bound=BaseColumn)
18
18
 
19
19
  # 전역 데이터베이스 서비스 인스턴스
20
- _database_service: 'DatabaseService' | None = None
20
+ _database_service: Union['DatabaseService', None] = None
21
21
 
22
22
  def get_database_service() -> 'DatabaseService':
23
23
  """DatabaseService 인스턴스를 반환하는 함수
@@ -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
@@ -5,63 +5,7 @@ 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: 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
  """서비스 레지스트리를 관리하는 클래스"""
@@ -0,0 +1,2 @@
1
+ """버전 정보"""
2
+ __version__ = "0.2.16"
@@ -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()
@@ -1,2 +0,0 @@
1
- """버전 정보"""
2
- __version__ = "0.2.14"
File without changes
File without changes
File without changes