Skip to content

Conversation

@thezz9
Copy link
Collaborator

@thezz9 thezz9 commented Jun 14, 2025

해결해야 할 문제

  • 일단 SSE 수신은 됩니다.
  • 레디스 스트림에서 꺼내서 병행 처리를 위해 비동기 메서드를 호출하는데
  • 이 부분에서 Security 정보가 전파가 안 되는 문제가 있습니다.. 이건 튜터님들한테 월요일에 여쭤봐야할 것 같아요
  • 해결 못 하겠어요 ㅠ

참고 사항

  • 병목 현상 제거를 위해 비동기로 요청, Judge0 까지 병행으로 요청하는데 저희 컴파일 서버 시스템 사양이 낮아서 병목현상 제거가 제대로 안 됩니다. 요청을 20개 씩 보내도 워커가 최대 2개 뿐이라 병목이 계속 생겨요.
  • 리베이스 하고 푸시했는데도 다른 분들 이미 dev 브랜치로 머지된 것들이 저한테 딸려서 오네요..? 문제 생기면 말씀해주세요

Summary by CodeRabbit

  • 신규 기능

    • 게임 도메인(캐릭터, 인벤토리, 아이템, 장비, 스킬, 전투 등) 관련 엔티티, 서비스, 컨트롤러 추가
    • 게임 아이템 생성, 캐릭터 생성, 인벤토리 관리, 아이템 뽑기/장착 기능 제공
    • MongoDB 및 Redis 연동, 비동기 처리 및 큐 기반 채점 시스템 도입
    • SSE(서버 전송 이벤트) 기반 코드 제출/채점 결과 스트리밍 지원
  • 버그 수정 및 개선

    • 인증/인가 오류 시 JSON 기반 에러 응답 제공
    • 채팅/채점 이벤트 DTO 및 핸들러 명확한 이름으로 변경
    • 일부 컨트롤러 및 API 경로 /api로 통일
  • 문서화

    • 주요 API에 Swagger(OpenAPI) 문서화 어노테이션 추가
  • 환경설정

    • MongoDB, Redis, MapStruct 등 의존성 및 환경 변수 추가
  • 기타

    • 코드 리팩터링 및 내부 구조 개선, 예외 코드 표준화, 로깅 및 에러 처리 강화

thezz9 and others added 17 commits June 13, 2025 18:32
* refactor : logout HttpServeletRequest를 컨트롤러에서 String으로 추출 후 service로 전달

* refactor : whitelist 등록

* refactor : 에러 발생 시, html응답 대신 Json응답으로 받을 수 있도록 리팩토링

* refactor : requestMapping으로 앞에 일괄적으로 /api 달기
* feat : 게임 도메인 엔티티 생성 및 스킬, 아이템 효과 정의

* feat : 게임 도메인 서비스, 아이템 뽑기 도메인서비스 추가, 랜덤 인카운터 추가

* feat : 아이템 장착, 뽑기, 인벤토리 오픈, 스탯 확인, 캐릭터 생성 기능 추가

# Conflicts:
#	src/main/java/org/ezcode/codetest/common/security/config/SecurityConfig.java

* chore : properties 수정

* chore : properties 수정

* chore : securityconfig 오타수정

* chore : 오타수정

* chore : 오타수정

* chore : 무수히 많은 오타수정, 누락된 어노테이션 추가

* docs : 환경변수 추가

* docs : 오타수정

---------

Co-authored-by: pokerbearkr <[email protected]>
* refactor : api 경로 추가, oauth 경로 수정

* refactor : whitelist 경로 수정

* refactor : redirect url 수정
@thezz9 thezz9 self-assigned this Jun 14, 2025
@thezz9 thezz9 added the enhancement New feature or request label Jun 14, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 14, 2025

Caution

Review failed

The pull request is closed.

"""

Walkthrough

이 변경사항은 게임 도메인(캐릭터, 아이템, 인벤토리, 도메인 서비스, 컨트롤러)과 제출(Submission) 시스템에 대규모 기능을 추가 및 리팩토링합니다. MongoDB와 Redis를 활용한 저장소 및 큐 기반 비동기 처리, OpenAPI 문서화, 인증/보안 흐름 개선, 채팅/이벤트 네이밍 정비, 다양한 도메인 엔티티 및 DTO 추가가 포함됩니다.

Changes

파일/그룹 변경 요약
.github/workflows/ci.yml, application.properties MongoDB 환경변수 및 설정 추가
build.gradle MongoDB, MapStruct, Redis 등 의존성 추가
src/main/java/org/ezcode/codetest/application/chatting/dto/request/ChatRoomDeleteRequest.java
src/main/java/org/ezcode/codetest/application/chatting/dto/request/ChatRoomSaveRequest.java
src/main/java/org/ezcode/codetest/application/chatting/dto/request/ChatSaveRequest.java
src/main/java/org/ezcode/codetest/application/chatting/dto/response/ChatResponse.java
src/main/java/org/ezcode/codetest/application/chatting/dto/response/RoomChangedResponse.java
OpenAPI(Swagger) 스키마 어노테이션 추가
src/main/java/org/ezcode/codetest/application/game/dto/mapper/GameMapper.java
src/main/java/org/ezcode/codetest/application/game/dto/request/.java
src/main/java/org/ezcode/codetest/application/game/dto/response/
.java
게임 아이템/캐릭터 관련 DTO, 매퍼, 응답 객체 신설
src/main/java/org/ezcode/codetest/application/game/management/GameAdminUseCase.java
src/main/java/org/ezcode/codetest/application/game/play/GamePlayUseCase.java
게임 관리/플레이 유스케이스 서비스 신설
src/main/java/org/ezcode/codetest/application/submission/dto/response/submission/GroupedSubmissionResponse.java
src/main/java/org/ezcode/codetest/application/submission/model/SubmissionContext.java
src/main/java/org/ezcode/codetest/application/submission/port/*.java
src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java
제출(Submission) 비동기 큐 기반 처리, SSE emitter store 및 메시지 구조 신설, 제출 grouping 개선
src/main/java/org/ezcode/codetest/application/usermanagement/auth/service/AuthService.java logout, refreshToken 메서드 시그니처 변경 및 토큰 추출 로직 분리
src/main/java/org/ezcode/codetest/common/config/AsyncEnableConfig.java
src/main/java/org/ezcode/codetest/common/config/ExecutorConfig.java
비동기/스레드풀 설정 신설
src/main/java/org/ezcode/codetest/common/security/config/SecurityConfig.java
src/main/java/org/ezcode/codetest/common/security/util/ExceptionHandlingFilter.java
src/main/java/org/ezcode/codetest/common/security/util/JwtFilter.java
인증/인가 실패 시 JSON 에러 응답, JWT 화이트리스트 및 예외 처리 개선
src/main/java/org/ezcode/codetest/domain/game/Util/StatUpdateUtil.java
src/main/java/org/ezcode/codetest/domain/game/exception/.java
src/main/java/org/ezcode/codetest/domain/game/model/entity/
.java
src/main/java/org/ezcode/codetest/domain/game/model/enums/.java
src/main/java/org/ezcode/codetest/domain/game/repository/
.java
src/main/java/org/ezcode/codetest/domain/game/service/*.java
게임 도메인(캐릭터, 인벤토리, 아이템, 확률뽑기, 예외 등) 엔티티, 서비스, 저장소 신설
src/main/java/org/ezcode/codetest/domain/submission/exception/code/SubmissionExceptionCode.java
src/main/java/org/ezcode/codetest/domain/submission/model/TestcaseEvaluationInput.java
src/main/java/org/ezcode/codetest/domain/submission/service/SubmissionDomainService.java
제출 예외코드 추가, 평가 입력 구조 신설, 평가/통계 로직 리팩토링
src/main/java/org/ezcode/codetest/infrastructure/cache/config/RedisCacheConfig.java 클래스명 변경(CacheRedisConfig → RedisCacheConfig)
src/main/java/org/ezcode/codetest/infrastructure/event/config/RedisStreamConfig.java
src/main/java/org/ezcode/codetest/infrastructure/event/dto/SubmissionMessage.java
src/main/java/org/ezcode/codetest/infrastructure/event/listener/RedisJudgeQueueConsumer.java
src/main/java/org/ezcode/codetest/infrastructure/event/scheduler/RedisStreamCleanupScheduler.java
src/main/java/org/ezcode/codetest/infrastructure/event/service/RedisJudgeQueueProducer.java
Redis Stream 기반 큐/컨슈머/프로듀서/스케줄러 신설
src/main/java/org/ezcode/codetest/infrastructure/event/dto/*.java
src/main/java/org/ezcode/codetest/infrastructure/event/listener/ChatEventListener.java
src/main/java/org/ezcode/codetest/infrastructure/event/service/ChatEventPublisher.java
채팅/이벤트 DTO 및 이벤트 리스너/퍼블리셔 네이밍 개선
src/main/java/org/ezcode/codetest/infrastructure/mongodb/config/.java
src/main/java/org/ezcode/codetest/infrastructure/mongodb/repository/
.java
MongoDB 커스텀 컨버터, 저장소, 레포지토리 구현 신설
src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/chat/ChatRepositoryImpl.java
src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/chat/ChatRoomRepositoryImpl.java
@OverRide 어노테이션 추가
src/main/java/org/ezcode/codetest/infrastructure/persistence/repository/game/*.java 게임 캐릭터/인벤토리 JPA/레포지토리 구현 신설
src/main/java/org/ezcode/codetest/infrastructure/sse/InMemoryEmitterStore.java 인메모리 SSE emitter 저장소 구현
src/main/java/org/ezcode/codetest/infrastructure/judge0/Judge0Client.java Judge0 연동 비동기 제출/폴링 방식으로 분리, 에러처리 강화
src/main/java/org/ezcode/codetest/presentation/chattingmanagement/chatting/controller/ChatRoomController.java OpenAPI 어노테이션 추가
src/main/java/org/ezcode/codetest/presentation/chattingmanagement/event/EventHandleController.java 메서드명 직관적으로 변경
src/main/java/org/ezcode/codetest/presentation/game/management/ItemManagementController.java
src/main/java/org/ezcode/codetest/presentation/game/play/GamePlayController.java
게임 아이템/플레이 REST 컨트롤러 신설
src/main/java/org/ezcode/codetest/presentation/language/LanguageController.java API 경로 /languages → /api/languages 변경
src/main/java/org/ezcode/codetest/presentation/submission/SubmissionController.java /api 프리픽스 추가, SSE 제출 메서드 서비스 호출 변경, 예시 확장, Slf4j 추가
src/main/java/org/ezcode/codetest/presentation/usermanagement/AuthController.java
src/main/java/org/ezcode/codetest/presentation/usermanagement/UserController.java
/api 프리픽스 추가, AuthController에서 토큰 추출 및 검증 로직 컨트롤러로 이동
src/main/java/org/ezcode/codetest/presentation/usermanagement/view/AuthViewController.java 소셜 로그인 시 Google OAuth2로 리다이렉트
src/main/resources/templates/login-page.html Google 로그인 링크 OAuth2 엔드포인트로 변경
src/main/resources/templates/submit-test.html 제출/리뷰 요청 URL에 /api 프리픽스 추가

Sequence Diagram(s)

제출(Submission) 비동기 처리 및 채점 흐름

sequenceDiagram
    participant Client
    participant SubmissionController
    participant SubmissionService
    participant QueueProducer (Redis)
    participant RedisJudgeQueueConsumer
    participant JudgeClient
    participant SubmissionDomainService
    participant EmitterStore

    Client->>SubmissionController: POST /api/problems/{id}/submit-stream
    SubmissionController->>SubmissionService: enqueueCodeSubmission()
    SubmissionService->>EmitterStore: save(emitterKey, emitter)
    SubmissionService->>QueueProducer: enqueue(SubmissionMessage)
    SubmissionController-->>Client: SseEmitter (즉시 반환)

    RedisJudgeQueueConsumer->>SubmissionService: submitCodeStream(SubmissionMessage)
    SubmissionService->>JudgeClient: submitAndGetToken()
    loop 각 테스트케이스
        SubmissionService->>JudgeClient: pollUntilDone(token)
        JudgeClient-->>SubmissionService: JudgeResult
        SubmissionService->>SubmissionDomainService: handleEvaluationAndUpdateStats()
        SubmissionService->>EmitterStore: get(emitterKey)
        SubmissionService-->>Client: SSE partial result
    end
    SubmissionService-->>Client: SSE final result
    SubmissionService->>EmitterStore: remove(emitterKey)
Loading

게임 아이템 뽑기 및 인벤토리 처리

sequenceDiagram
    participant Client
    participant GamePlayController
    participant GamePlayUseCase
    participant ItemShoppingDomainService
    participant CharacterStatusDomainService
    participant ItemRepository
    participant InventoryRepository

    Client->>GamePlayController: POST /games/gamblings
    GamePlayController->>GamePlayUseCase: gamblingForItem(userId, itemCategory)
    GamePlayUseCase->>ItemShoppingDomainService: gamblingNewWeapon/Defence/Accessory()
    ItemShoppingDomainService->>ItemRepository: findAllByItemCategory()
    ItemShoppingDomainService->>InventoryRepository: findByGameCharacterId()
    ItemShoppingDomainService-->>GamePlayUseCase: Item
    GamePlayUseCase-->>GamePlayController: ItemGamblingResponse
    GamePlayController-->>Client: 201 Created + ItemGamblingResponse
Loading

Possibly related PRs

Suggested reviewers

  • minjee2758
  • pokerbearkr
  • NCookies

Poem

🐰
새싹처럼 돋아난 코드의 숲,
게임과 제출, 채팅도 술술,
몽고와 레디스, 큐로 춤추니
비동기 물결에 토끼도 방긋!
컨트롤러, 서비스, 도메인까지
모두모두 새로워진 우리 집,
API 문서도 반짝반짝,
코드를 사랑하는 토끼의 봄날!
🥕
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@thezz9 thezz9 merged commit 9c93a71 into dev Jun 14, 2025
1 of 2 checks passed
@thezz9 thezz9 deleted the refactor/submission-stream branch June 14, 2025 13:00
@coderabbitai coderabbitai bot mentioned this pull request Jun 17, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants