Skip to content
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

[FEAT] 대기열 구현 #32

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

[FEAT] 대기열 구현 #32

wants to merge 9 commits into from

Conversation

tnals2384
Copy link
Collaborator

📌 과제 설명

대기열 서비스를 구현했습니다.

👩‍💻 요구 사항과 구현 내용

1. 큐 진입 API (토큰발급)

1. 처리 큐에 1000명(임시) 이 차기 전까진 처리 큐에 우선 진입
2. 1000명 넘으면 대기 큐에 진입
3. 처리 큐나 대기 큐에 이미 존재하는 userId 거부

2. 큐 정보 반환 요청 API (상태랑 대기 수)

  • 예상 남은 시간은 아직 어떻게 하는지 잘 모르겠습니다.. 연구가 필요해요 🥹

3. 대기 큐 탈출 API

  • 대기 큐에서 토큰을 제거

4. 예매 성공 시 진행 큐 탈출 요청 함수 작성

5. 30초마다 대기큐 -> 처리큐 Update 스케줄러 작성

1. 먼저 유효시간만료 토큰을 체크하여 대기 큐, 처리 큐에서 제거
2. 처리큐에서 빈 만큼, 대기큐 -> 처리큐 이동

✅ PR 포인트 & 궁금한 점

빼먹은게 있으면 편하게 말씀 주쎄요~!
그리고 yml 파일을 따로 .gitignore 처리 해두지 않아서 jwt관련 정보들이 공개되어있는데, 임시니까 일단 공개해둡니다!!

Copy link
Collaborator

@AnTaeho AnTaeho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

엄청 잘 짜셔서 특별히 리뷰 남길만한게 별로 없네요...
저도 나름 잘 짰다고 생각했는데 처리를 휠씬 세세하게 잘 하신것 같습니다!

제가 아까 보니까 수민님만 메인 브랜치에 머지를 못해봐서 컨트리뷰터에 이름이 없던데
코드도 잘 작성하신거 같고 제 코드 리뷰후에 적당히 합쳐서 수민님 코드로 머지하셔도 좋을 것 같습니다!
고생하셨습니다~

Comment on lines +23 to +30
private final SecretKey secretKey;
private final Integer expirationTime;
private static final String SIGNATURE_ALGORITHM = Jwts.SIG.HS256.key().build().getAlgorithm();

JwtUtil(@Value("${jwt.secret}") String secretKey, @Value("${jwt.expiration_time}") Integer expirationTime) {
this.secretKey = new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), SIGNATURE_ALGORITHM);
this.expirationTime = expirationTime;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사실 저는 무슨 auth0-jwt 였나 하는 라이브러리만 써보고
jjwt 라이브러리를 처음 써봐서 엄청 엉성한데 한 수 배워갑니다.

Comment on lines +11 to +14
@Service
@Transactional
@RequiredArgsConstructor
public class QueueServiceImpl implements QueueService {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3
여기에 @transactional은 필요 없지 않을까요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그로네용..습관이 무섭습니다....

Comment on lines +15 to +20
@Scheduled(fixedRate = 30 * 1000) //30초마다
public void updateWaitingToProcessing() {
queueCommandService.removeExpiredToken();
queueCommandService.updateWaitingToProcessing();
log.info("processing queue 가 update 되었습니다.");
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 만료된 토큰 제거는 생각하지도 않았네요 ㅜㅠㅠㅠ

import static com.example.book_your_seat.queue.QueueConst.*;
import static org.junit.jupiter.api.Assertions.*;

public class QueueServiceTest extends IntegralTestSupport {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 테스트의 for들이 전부 1000번 부터 시작하는데 이유가 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그냥 혹시라도 아까처럼 id문제가 생길까봐 안전하게 했습니다 ㅎㅎㅎ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Redis를 이용한 대기열 구현
2 participants