[ 4주차 ] Ratelimit 구현 및 테스트 케이스 작성#97
Merged
soonhankwon merged 16 commits intohanghae-skillup:futuremaker019from Feb 4, 2025
Merged
[ 4주차 ] Ratelimit 구현 및 테스트 케이스 작성#97soonhankwon merged 16 commits intohanghae-skillup:futuremaker019from
soonhankwon merged 16 commits intohanghae-skillup:futuremaker019from
Conversation
- 분산락이 해제된 후, DB 트랜젝션의 lost update 상황을 방지하기 위해 적용
|
안녕하세요 구현님 😃 |
soonhankwon
reviewed
Feb 4, 2025
| } | ||
|
|
||
| // Redis에서 요청 횟수 증가 및 초과 체크 | ||
| if (rateLimiterHandler.isRequestLimitExceeded(ip)) { |
There was a problem hiding this comment.
Redis를 활용해서 rateLimter 구현을 적절하게 잘 해주신점 좋네요 👍
- 알맞은 응답(429)를 반환하는 점도 좋습니다.
soonhankwon
reviewed
Feb 4, 2025
| import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
|
||
| @SpringBootTest |
soonhankwon
reviewed
Feb 4, 2025
| Thread.sleep(1000); | ||
| } catch (Exception e) { | ||
| // 예외가 발생하면 계속해서 실패 메시지 출력 | ||
| System.out.println("Request " + (i + 1) + " failed due to: " + e.getMessage()); |
There was a problem hiding this comment.
System.out 보다는 로깅을 활용하는편이 성능상 좋습니다 :)
soonhankwon
reviewed
Feb 4, 2025
|
|
||
| @DisplayName("") | ||
| @DisplayName("좌석 5개 이상 예약 시도 시, 예외를 발생시킨다.") | ||
| @Test |
soonhankwon
reviewed
Feb 4, 2025
| .header("X-Forwarded-For", ip) | ||
| ) | ||
| .andDo(print()) | ||
| .andExpect(status().isTooManyRequests()); // 요청이 초과되어 429 Too Many Requests 응답 |
There was a problem hiding this comment.
Ratelimit가 적용된 "실패해야하는 부분"에 대한 테스트 작성되있어서 좋습니다 👍
soonhankwon
reviewed
Feb 4, 2025
| private final ReservationMessageSender messageSender; | ||
|
|
||
| @Async | ||
| @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT) |
There was a problem hiding this comment.
이벤트리스너활용 & 비동기처리로 메서지전송 로직과 결합도를 낮춰주신점 좋네요 👍
좋았던 점
아쉬웠던 점
리뷰 포인트
|
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.
제목(title)
[ 4주차 ] Ratelimit 구현 및 테스트 케이스 작성
작업 내용
작업내용 입니다.
작업은 인터셉터를 이용해서 Redis 캐시를 이용해 개발했습니다.
테스트 케이스를 작성했지만 부족한 부분이 있어, 다음주까지 보충하여 제출하겠습니다. (lua script 및 Jacoco 포함)
발생했던 문제와 해결 과정을 남겨 주세요.
이번 주차에서 고민되었던 지점이나, 어려웠던 점을 알려 주세요.
리뷰 포인트