refactor: 영상 분석 파이프라인에서 S3 업로드 분리 (#63)#79
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the file storage and processing logic by introducing a dedicated 'LocalFileStorage' component and a 'FileExtensions' utility, while also updating 'S3FileStorage' to include retry logic for S3 operations. The 'AnalysisCompletionTracker' has been improved to better manage task states and cleanup, and 'VideoAnswerProcessor' has been updated to use the new storage components. I have provided feedback suggesting more specific exception handling in 'LocalFileStorage' and the use of 'String.format' for better readability when constructing S3 keys.
| } catch (Exception e) { | ||
| log.error("[로컬파일] 저장 실패 - filename: {}", file.getOriginalFilename(), e); | ||
| throw new BusinessException(ErrorCode.INTERNAL_ERROR); | ||
| } |
There was a problem hiding this comment.
포괄적인 Exception 대신 더 구체적인 IOException을 catch하는 것이 좋습니다. file.transferTo()와 Files.createTempFile()은 주로 IOException을 발생시키며, 이는 예측 가능한 I/O 오류입니다. IllegalStateException과 같은 다른 런타임 예외는 애플리케이션의 전역 예외 처리기에서 처리되도록 두는 것이 더 나은 설계일 수 있습니다. 이렇게 하면 예외 처리 로직이 더 명확해지고 의도치 않은 예외를 숨기는 것을 방지할 수 있습니다.
| } catch (Exception e) { | |
| log.error("[로컬파일] 저장 실패 - filename: {}", file.getOriginalFilename(), e); | |
| throw new BusinessException(ErrorCode.INTERNAL_ERROR); | |
| } | |
| } catch (IOException e) { | |
| log.error("[로컬파일] 저장 실패 - filename: {}", file.getOriginalFilename(), e); | |
| throw new BusinessException(ErrorCode.INTERNAL_ERROR); | |
| } |
| ) | ||
| public String save(Path videoPath, String contentType, String email) { | ||
| String extension = FileExtensions.extract(videoPath.getFileName().toString()); | ||
| String key = "interview-video/" + email + "/" + LocalDate.now() + "/" + UUID.randomUUID() + extension; |
There was a problem hiding this comment.
여러 문자열을 + 연산자로 연결하는 것보다 String.format()을 사용하면 코드가 더 읽기 쉽고 유지보수하기 좋아집니다. 특히 S3 키와 같이 구조가 정해진 문자열을 만들 때 가독성 향상에 도움이 됩니다.
| String key = "interview-video/" + email + "/" + LocalDate.now() + "/" + UUID.randomUUID() + extension; | |
| String key = String.format("interview-video/%s/%s/%s%s", email, LocalDate.now(), UUID.randomUUID(), extension); |
📌 관련 이슈 (Related Issue)
📝 작업 내용 (Description)
external.storage패키지에 일원화@Retryable추가🔄 변경 유형 (Type of Change)
✅ 체크리스트 (Checklist)