refactor: 계좌 연동과 소비 분류 비동기 분리 - #236
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
관련 이슈
배경
기존 계좌 연동 API는 계좌와 거래내역을 저장한 뒤 소비 분류가 완료될 때까지 기다리고 응답했습니다.
소비 분류 시간이 길어지면 사용자가 계좌 연동 화면에서 장시간 로딩을 기다려야 했습니다.
계좌·거래 저장이 끝나면 계좌 연동 응답을 반환하고, 소비 분류는 백그라운드에서 계속 처리하도록 두 작업을 분리했습니다.
기존 구조
변경 구조
계좌 연동 요청
→ 계좌 및 거래 저장
→ 소비 분류 이벤트 등록
→ 계좌 연동 API 응답
↓
전용 executor에서 소비 분류
↓
TXN_ANALYSIS 저장
변경 내용
1. 계좌 연동과 소비 분류 분리
2. 전용 executor 구성
소비 분류 작업이 웹 요청 스레드 및 기존 FastAPI 배치 executor를 점유하지 않도록 전용 executor를 추가했습니다.
기본 설정:
account.classification.async.core-pool-size=1
account.classification.async.max-pool-size=2
account.classification.async.queue-capacity=100
설정 파일이 없어도 위 기본값으로 동작합니다.
선택적으로 다음 외부 설정 파일에서 조정할 수 있습니다.
${NTROPY_CONFIG_DIR}/account-classification.properties
3. 중복 실행 방지
4. 실패 격리
5. 로그 추가
[비동기 소비 분류] 작업 시작.
scope=userId=...
[비동기 소비 분류] 작업 완료.
scope=userId=..., totalProcessed=..., elapsedMs=...
[비동기 소비 분류] 작업 실패.
scope=userId=..., elapsedMs=..., errorKind=...
[비동기 소비 분류] 작업 등록 실패.
scope=userId=..., errorKind=...
거래 원문, 인증정보 및 API 키는 기록하지 않습니다.
테스트
다음 항목을 검증했습니다.
실행 결과:
.\gradlew.bat :services:account-service:test :services:ai-service:test --no-daemon
BUILD SUCCESSFUL
.\gradlew.bat :api:war --no-daemon
BUILD SUCCESSFUL
로컬 Tomcat 실행 및 Swagger 접근도 확인했습니다.
DB 변경
배포 설정
필수로 추가해야 하는 환경변수나 외부 설정은 없습니다. 설정이 없으면 기본 executor 설정으로 실행됩니다.
배포 후 확인
범위 외