Refactor: 문서 썸네일 구현 #195
Merged
Merged
Conversation
- 문서 생성 시 썸네일 메타데이터 생성 - 저장 응답에 썸네일 동기화 정보 포함 - requestToken 검증 기반 썸네일 확정 API 추가 - 문서 목록 preview를 thumbnailUrl/status로 대체
- 썸네일 교체 시 이전 썸네일 이미지를 S3 삭제 아웃박스에 적재 - S3 삭제 워커와 재시도/완료 상태 처리 추가 - OutboxStatus와 BaseOutboxEntity를 공통 패키지로 분리 - Mongo 삭제 아웃박스를 global.outbox.mongo 패키지로 이동 - 관련 단위 테스트 추가 및 패키지 변경에 따른 테스트 수정
- Mongo/S3 oubox claim을 OPEN 조건부 update 쿼리로 변경 - 여러 worker가 같은 OPEN row를 중복 처리하지 않도록 방지 - PROCESSING timeout 복구 시 retryCount를 증가시키지 않도록 분리 - timeout 복구 정책 변경에 맞춰 통합 테스트 기대값 수정
…및 application.yml 환경별 수정
Chore: Flyway 기반 DB 마이그레이션 도입
test: preview와 썸네일 워크플로우 성능 테스트 추가
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.
🛰️ Issue Number
🪐 작업 내용
1. 문서 썸네일 도메인 추가
Thumbnail엔티티를 추가했습니다.Thumbnailrow를 함께 생성하도록 변경했습니다.EMPTY,PENDING,READY,FAILED로 관리합니다.requestToken을 증가시켜 오래된 썸네일 생성 결과가 최신 결과를 덮어쓰지 않도록 했습니다.주요 흐름:
PUT /api/document/{docId}/thumbnail로 썸네일 확정requestToken, 문서 소유자, 이미지 상태, 이미지 목적을 검증sequenceDiagram participant FE as Frontend participant SAVE as Save API participant IMG as Image API participant S3 as S3 participant TH as Thumbnail API FE->>SAVE: PUT /api/document/{docId}/save/{saveId} SAVE->>SAVE: 문서 저장 + Thumbnail.requestToken++ SAVE-->>FE: updatedAt + requestToken + signature + status FE->>FE: 현재 상단 signature 계산 alt signature 동일 FE->>FE: 썸네일 업로드 생략 else signature 다름 FE->>IMG: POST /api/images/upload-url purpose=DOC_THUMBNAIL IMG-->>FE: imageId + uploadUrl FE->>S3: PUT presigned URL FE->>IMG: POST /api/images/{imageId}/complete FE->>TH: PUT /api/document/{docId}/thumbnail TH->>TH: requestToken 최신 여부 검증 TH-->>FE: 대표 썸네일 READY end2. 썸네일 확정 API 추가
ThumbnailController를 추가해 문서 대표 썸네일 확정 API를 제공하도록 했습니다.ACTIVE)DOC_THUMBNAIL)3. 문서 목록 응답을 썸네일 기반으로 변경
DocPageResponse에thumbnailUrl,thumbnailStatus를 추가했습니다.DocListAssembler에서 문서 목록 조회 시 썸네일과 현재 이미지를 fetch join으로 조회해 목록 응답을 구성하도록 변경했습니다.4. 이미지 업로드 목적 분리
Image에Purpose를 추가했습니다.DOC_CONTENTDOC_THUMBNAILpurpose를 추가했습니다.users/{userId}/docs/{docId}/images/{uuid}.{ext}users/{userId}/docs/{docId}/thumbnails/{uuid}.{ext}5. 썸네일 교체 시 이전 S3 객체 삭제 Outbox 추가
DELETED로 변경합니다.404)는 최종 목표가 달성된 것으로 보고 성공 처리합니다.6. Outbox 공통화 및 Mongo Outbox 패키지 정리
BaseOutboxEntity로 분리했습니다.statusretryCountmaxRetrydoneAtlastErrorversionOutboxStatus를 공통 enum으로 분리했습니다.global.mongo.outbox에서global.outbox.mongo로 이동했습니다.global.outbox.s3하위에 구성했습니다.7. Outbox worker 안정성 개선
OPEN -> PROCESSING조건부 update 쿼리로 변경했습니다.OPENrow를 동시에 처리하지 않도록 DB update의 원자성을 활용했습니다.PROCESSING상태에서 일정 시간 이상 멈춘 row는 worker 시작 시 다시OPEN으로 복구하도록 했습니다.retryCount를 증가시키지 않도록 분리했습니다.8. 문서 및 테스트 정리
purpose필드를 반영했습니다.📚 Reference
@Modifyingupdate query✅ Check List