aiteamutils 0.2.40__tar.gz → 0.2.41__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.40
3
+ Version: 0.2.41
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
@@ -685,16 +685,33 @@ class DatabaseService:
685
685
 
686
686
  Returns:
687
687
  생성된 로그 엔티티
688
- """
689
- # 공통 필드 추가 (ULID를 문자열로 변환)
690
- log_data["ulid"] = str(ULID())
691
-
692
- # request가 있는 경우 user-agent와 ip 정보 추가
693
- if request:
694
- log_data["user_agent"] = request.headers.get("user-agent")
695
- log_data["ip_address"] = request.headers.get("x-forwarded-for")
696
688
 
697
- return await self.create_entity(model, log_data)
689
+ Raises:
690
+ CustomException: 로그 생성 실패 시
691
+ """
692
+ try:
693
+ # 공통 필드 추가 (ULID를 문자열로 변환)
694
+ log_data["ulid"] = str(ULID())
695
+
696
+ # request가 있는 경우 user-agent와 ip 정보 추가
697
+ if request:
698
+ log_data["user_agent"] = request.headers.get("user-agent")
699
+ log_data["ip_address"] = request.headers.get("x-forwarded-for")
700
+
701
+ # 데이터 전처리
702
+ processed_data = self.preprocess_data(model, log_data)
703
+ entity = model(**processed_data)
704
+
705
+ # 로그 엔티티 저장
706
+ self.db.add(entity)
707
+ await self.db.flush()
708
+
709
+ return entity
710
+
711
+ except Exception as e:
712
+ logging.error(f"Failed to create log: {str(e)}")
713
+ # 로그 생성 실패는 원래 작업에 영향을 주지 않도록 함
714
+ return None
698
715
 
699
716
  async def soft_delete(
700
717
  self,
@@ -0,0 +1,2 @@
1
+ """버전 정보"""
2
+ __version__ = "0.2.41"
@@ -1,2 +0,0 @@
1
- """버전 정보"""
2
- __version__ = "0.2.40"
@@ -1,54 +0,0 @@
1
- async def startup_event() -> None:
2
- """Application startup event handler."""
3
- try:
4
- # 1. 설정 및 DB 초기화
5
- init_settings(
6
- jwt_secret=settings.JWT_SECRET,
7
- jwt_algorithm=settings.JWT_ALGORITHM,
8
- db_url=settings.CORE_DB_URL,
9
- db_echo=settings.DB_ECHO,
10
- db_pool_size=settings.DB_POOL_SIZE,
11
- db_max_overflow=settings.DB_MAX_OVERFLOW,
12
- db_pool_timeout=settings.DB_POOL_TIMEOUT,
13
- db_pool_recycle=settings.DB_POOL_RECYCLE
14
- )
15
- db_service = get_database_service()
16
-
17
- if not db_service or not db_service.engine:
18
- raise RuntimeError("데이터베이스 서비스 초기화 실패")
19
-
20
- # 2. DB 연결 테스트
21
- async with db_service.engine.begin() as conn:
22
- await conn.run_sync(lambda _: None)
23
- logging.info("데이터베이스 연결 성공")
24
-
25
- # 3. 테이블 생성
26
- async with db_service.engine.begin() as conn:
27
- await conn.run_sync(Base.metadata.create_all)
28
- logging.info("데이터베이스 테이블 생성 완료")
29
-
30
- # 4. 서비스 등록
31
- register_services()
32
- service_registry.set_initialized() # 서비스 등록 완료 표시
33
-
34
- logging.info("서비스 등록 완료")
35
-
36
- except Exception as e:
37
- logging.error(f"애플리케이션 시작 실패: {str(e)}")
38
- raise RuntimeError(f"애플리케이션 시작 실패: {str(e)}")
39
-
40
- async def shutdown_event() -> None:
41
- """Application shutdown event handler."""
42
- try:
43
- # 1. 서비스 레지스트리 초기화
44
- service_registry.clear()
45
- logging.info("서비스 레지스트리 초기화 완료")
46
-
47
- # 2. 데이터베이스 연결 종료
48
- db_service = get_database_service()
49
- if db_service and db_service.engine:
50
- await db_service.engine.dispose()
51
- logging.info("데이터베이스 연결 종료")
52
- except Exception as e:
53
- logging.error(f"애플리케이션 종료 중 오류 발생: {str(e)}")
54
- raise
File without changes
File without changes
File without changes
File without changes