-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 메인페이지 공지사항 크롤링 비동기 처리 #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 공지사항 크롤링 요청 총 5번을 비동기 처리로 시간 단축
|
공지사항 기능의 요청을 비동기 처리하여 성능을 개선함.
|
cjh-19
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
공지사항 비동기 처리 코드 리뷰 완료
| ); | ||
| try { | ||
| // 공지사항 비동기 호출 | ||
| CompletableFuture<List<MainResponseDto.NoticeItem>> generalNotices = CompletableFuture.supplyAsync(() -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- CompletableFuture.supplyAsync()를 사용하여 공지사항 데이터를 병렬로 가져옴
- 각 카테고리("", "0", "1", "2", "4")의 데이터를 별도로 호출하여 병렬 처리
| .collect(Collectors.toList()) | ||
| : List.of(); | ||
| // 모든 공지사항 작업 완료 대기 | ||
| CompletableFuture.allOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- CompletableFuture.allOf()로 동기화 -> 모든 CompletableFuture 작업이 완료될 때까지 대기
| events = (calendarResponseDto != null) ? calendarResponseDto.getEvents() : new CalendarResponseDto.EventGroup(); | ||
| } | ||
| // 공지사항 결과 병합 | ||
| MainResponseDto.Notices notices = new MainResponseDto.Notices( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Future.get()를 사용하여 각 결과를 가져와 MainResponseDto.Notices 객체로 병합
close: #218