[feat][queue-service] 대기열 진입 시 활성 프로그램 검증 + 스케줄러 활성 프로그램 판단 로직 수정#32
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: first-ticket/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthrough토큰 발급 전 프로그램 존재 여부와 활성 시간대를 검증하는 로직을 추가하고, 활성 프로그램 발견을 Redis 인프라에서 ProgramMeta 도메인으로 이동시켰습니다. 예외 정의, 도메인 검증 메서드, 저장소 쿼리 지원, 서비스 검증 통합, 스케줄러 마이그레이션, 테스트 정리가 포함됩니다. Changes프로그램 활성 상태 검증 및 발견 중앙화
Sequence DiagramsequenceDiagram
participant Client
participant QueueTokenService
participant ProgramMetaRepository
participant ProgramMeta
participant AdmissionScheduler
Client->>QueueTokenService: issueToken(userId, programId)
QueueTokenService->>QueueTokenService: validateProgramActive(programId)
QueueTokenService->>ProgramMetaRepository: findById(programId)
alt Program exists
ProgramMetaRepository-->>QueueTokenService: ProgramMeta
QueueTokenService->>ProgramMeta: ensureActiveAt(now)
alt Program is active
ProgramMeta-->>QueueTokenService: ok
QueueTokenService-->>Client: token issued
else Program not active
ProgramMeta-->>QueueTokenService: ProgramNotActiveException
QueueTokenService-->>Client: error (422)
end
else Program not found
ProgramMetaRepository-->>QueueTokenService: empty
QueueTokenService-->>Client: ProgramNotFoundException (404)
end
AdmissionScheduler->>ProgramMetaRepository: findActiveProgramIds(now)
ProgramMetaRepository-->>AdmissionScheduler: List<ProgramId>
AdmissionScheduler->>AdmissionScheduler: for each: admit tokens
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/java/com/firstticket/queueservice/queuetoken/application/QueueTokenService.java (1)
102-108: ⚡ Quick win활성 상태 판단/예외를 도메인 메서드로 위임해주세요.
Line 106-108에서 서비스가 도메인 상태를 조회해 분기하고 예외를 발생시키고 있습니다.
ProgramMeta가ensureActiveAt(now)같은 메서드로 자신의 불변식을 직접 보장하도록 옮기면 규칙 응집도가 더 좋아집니다.As per coding guidelines "비즈니스 규칙이 Service에 들어가지 않았는지 (도메인 메서드 호출만)" 및 "Tell, Don't Ask 원칙 위반 여부 (도메인 상태를 외부에서 가져와서 분기하는 코드)".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/main/java/com/firstticket/queueservice/queuetoken/application/QueueTokenService.java` around lines 102 - 108, The service-level validation in validateProgramActive currently fetches ProgramMeta and checks isActiveAt(...) then throws ProgramNotActiveException; move this business-rule into the domain by adding a method on ProgramMeta (e.g., ensureActiveAt(LocalDateTime now) or ensureActive()) that throws ProgramNotActiveException when not active, then change validateProgramActive to simply load ProgramMeta via programMetaRepository.findById(...) and call programMeta.ensureActiveAt(LocalDateTime.now()); remove the external if/throw logic so the domain object owns the invariant.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@src/main/java/com/firstticket/queueservice/queuetoken/application/QueueTokenService.java`:
- Around line 102-108: The service-level validation in validateProgramActive
currently fetches ProgramMeta and checks isActiveAt(...) then throws
ProgramNotActiveException; move this business-rule into the domain by adding a
method on ProgramMeta (e.g., ensureActiveAt(LocalDateTime now) or
ensureActive()) that throws ProgramNotActiveException when not active, then
change validateProgramActive to simply load ProgramMeta via
programMetaRepository.findById(...) and call
programMeta.ensureActiveAt(LocalDateTime.now()); remove the external if/throw
logic so the domain object owns the invariant.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: first-ticket/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 37efe7aa-5e08-4e5c-add8-4c81816a8a8c
📒 Files selected for processing (9)
src/main/java/com/firstticket/queueservice/programmeta/domain/ProgramMetaRepository.javasrc/main/java/com/firstticket/queueservice/queuetoken/application/QueueTokenService.javasrc/main/java/com/firstticket/queueservice/queuetoken/domain/QueueTokenRepository.javasrc/main/java/com/firstticket/queueservice/queuetoken/domain/exception/ProgramNotActiveException.javasrc/main/java/com/firstticket/queueservice/queuetoken/domain/exception/ProgramNotFoundException.javasrc/main/java/com/firstticket/queueservice/queuetoken/domain/exception/QueueErrorCode.javasrc/main/java/com/firstticket/queueservice/queuetoken/infrastructure/redis/RedisQueueTokenRepository.javasrc/main/java/com/firstticket/queueservice/queuetoken/infrastructure/scheduler/AdmissionScheduler.javasrc/test/java/com/firstticket/queueservice/queuetoken/infrastructure/redis/RedisQueueTokenRepositoryTest.java
💤 Files with no reviewable changes (2)
- src/main/java/com/firstticket/queueservice/queuetoken/domain/QueueTokenRepository.java
- src/test/java/com/firstticket/queueservice/queuetoken/infrastructure/redis/RedisQueueTokenRepositoryTest.java
코드래빗 리뷰 반영
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@src/main/java/com/firstticket/queueservice/programmeta/domain/ProgramMeta.java`:
- Around line 91-95: Add an explicit null-guard at the start of
ProgramMeta.ensureActiveAt so it validates the now parameter (instead of relying
on isActiveAt to throw an implicit NPE); if now is null throw an
IllegalArgumentException (e.g., "now must not be null"), then proceed to call
isActiveAt(now) and throw ProgramNotActiveException if needed. This ensures
ProgramMeta.ensureActiveAt and its contract are defensive against null inputs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: first-ticket/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3a1ef9bb-5a2e-4484-ac88-fc10faefc453
📒 Files selected for processing (3)
src/main/java/com/firstticket/queueservice/programmeta/domain/ProgramMeta.javasrc/main/java/com/firstticket/queueservice/programmeta/domain/exception/ProgramNotActiveException.javasrc/main/java/com/firstticket/queueservice/queuetoken/application/QueueTokenService.java
✅ Files skipped from review due to trivial changes (1)
- src/main/java/com/firstticket/queueservice/programmeta/domain/exception/ProgramNotActiveException.java
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/com/firstticket/queueservice/queuetoken/application/QueueTokenService.java
🌱 설명
대기열 진입 시 ProgramMeta 검증
QueueTokenService.issueToken: ProgramMeta 존재 + 활성 시간 검증ProgramNotFoundException(404)ProgramNotActiveException(422)AdmissionScheduler 활성 프로그램 판단 로직 정정
📌 관련 이슈
💻 커밋 유형
📝 체크리스트
📚 추가 설명
Summary by CodeRabbit
릴리스 노트
New Features
Bug Fixes