-
Notifications
You must be signed in to change notification settings - Fork 28
[4주차] Rate Limit 구현 및 Jacoco Report 생성 #75
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
base: jorippppong
Are you sure you want to change the base?
Conversation
|
@jorippppong 님, 안녕하세요~ 리뷰 시작하겠습니다. |
|
|
||
| -- 요청 내역 저장 | ||
| redis.call('SETEX', key, expire_time, '1') | ||
| return 1 |
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.
lua 파일로 별도로 분리해서 관리를 잘해주셨습니다 👍
| ttl = 1, | ||
| ttlTimeUnit = TimeUnit.MINUTES, | ||
| banTime = 1, | ||
| banTimeUnit = TimeUnit.HOURS |
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.
요구사항에 맞게 깔끔하게 구현해주셧네요 👍
| } | ||
|
|
||
| private String getClientIp() { | ||
| return request.getRemoteAddr(); // 프록시 서버는 고려 X |
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.
ip 도 request 에서 직접 받지 않고 잘 분리해주셨습니다!
|
|
||
| boolean allowed = strategy.isAllowed(rateLimit, getRequestUrl(), getClientIp()); | ||
| if (!allowed) { | ||
| throw new CoreException(CoreErrorCode.TOO_MANY_REQUEST); |
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.
TOO_MANY_REQUEST 예외처리도 좋습니다 :)
| return type == RateLimitType.RESERVATION; | ||
| } | ||
|
|
||
| private String generateRequestKey(String url, String ip) { |
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.
동일한 상영 시간대의 영화를 5분에 1번씩 할 수 있어야 하는데, screeningId 가 key 로 들어가도 괜찮지 않을까 싶습니다.
|
각 도메인 영역에 대한 테스트코드도 작성되면 좋을 것 같습니다. |
|
@jorippppong 님, 고생하셨습니다. 👍 👍 좋았던 점
아쉬웠던 점
질문에 대한 답변
|
[4주차] Rate Limit 구현 및 Jacoco Report 생성
📝작업 내용
🔒해결하려는 문제 혹은 고민이 되었던 부분을 남겨주세요.(문제 수 만큼 복사해서 사용할 것)
🔑해당 문제를 어떻게 해결했나요? 그리고 왜 그렇게 생각했는지 이유를 남겨주세요.(자세하게 남겨주실 수록 좋습니다.)
💬리뷰 요구사항(선택)
기타 사항 📌
추가로 언급할 사항이 있다면 여기에 적어주세요.