-
Notifications
You must be signed in to change notification settings - Fork 3
feature / refactor : 채점 시스템 SSE → WebSocket 기반으로 전환 #98
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/java/org/ezcode/codetest/application/submission/dto/event/SubmissionErrorEvent.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package org.ezcode.codetest.application.submission.dto.event; | ||
|
|
||
| import org.ezcode.codetest.domain.submission.exception.SubmissionException; | ||
| import org.ezcode.codetest.domain.submission.exception.code.SubmissionExceptionCode; | ||
|
|
||
| public record SubmissionErrorEvent( | ||
|
|
||
| String sessionKey, | ||
|
|
||
| SubmissionExceptionCode code | ||
|
|
||
| ) { | ||
| public SubmissionErrorEvent(String sessionKey, Throwable t) { | ||
| this(sessionKey, resolveCode(t)); | ||
| } | ||
|
|
||
| private static SubmissionExceptionCode resolveCode(Throwable t) { | ||
| if (t instanceof SubmissionException se) { | ||
| return (SubmissionExceptionCode) se.getResponseCode(); | ||
| } | ||
| return SubmissionExceptionCode.UNKNOWN_ERROR; | ||
| } | ||
| } | ||
12 changes: 12 additions & 0 deletions
12
.../org/ezcode/codetest/application/submission/dto/event/SubmissionJudgingFinishedEvent.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package org.ezcode.codetest.application.submission.dto.event; | ||
|
|
||
| import org.ezcode.codetest.application.submission.dto.event.payload.SubmissionFinalResultPayload; | ||
|
|
||
| public record SubmissionJudgingFinishedEvent( | ||
|
|
||
| String sessionKey, | ||
|
|
||
| SubmissionFinalResultPayload payload | ||
|
|
||
| ) { | ||
| } |
18 changes: 18 additions & 0 deletions
18
...ain/java/org/ezcode/codetest/application/submission/dto/event/TestcaseEvaluatedEvent.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.ezcode.codetest.application.submission.dto.event; | ||
|
|
||
| import org.ezcode.codetest.application.submission.dto.event.payload.TestcaseResultPayload; | ||
|
|
||
| public record TestcaseEvaluatedEvent( | ||
|
|
||
| String sessionKey, | ||
|
|
||
| TestcaseResultPayload payload | ||
|
|
||
| ) { | ||
| public static TestcaseEvaluatedEvent of(String sessionKey, TestcaseResultPayload payload) { | ||
| return new TestcaseEvaluatedEvent( | ||
| sessionKey, | ||
| payload | ||
| ); | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
...va/org/ezcode/codetest/application/submission/dto/event/TestcaseListInitializedEvent.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.ezcode.codetest.application.submission.dto.event; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.ezcode.codetest.application.submission.dto.event.payload.InitTestcaseListPayload; | ||
|
|
||
| public record TestcaseListInitializedEvent( | ||
|
|
||
| String sessionKey, | ||
|
|
||
| List<InitTestcaseListPayload> payload | ||
|
|
||
| ) { | ||
| public static TestcaseListInitializedEvent from(String sessionKey, List<InitTestcaseListPayload> payload) { | ||
| return new TestcaseListInitializedEvent(sessionKey, payload); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
...org/ezcode/codetest/application/submission/dto/event/payload/InitTestcaseListPayload.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package org.ezcode.codetest.application.submission.dto.event.payload; | ||
|
|
||
| import java.util.List; | ||
| import java.util.stream.IntStream; | ||
|
|
||
| import org.ezcode.codetest.domain.problem.model.ProblemInfo; | ||
| import org.ezcode.codetest.domain.problem.model.entity.Testcase; | ||
|
|
||
| public record InitTestcaseListPayload( | ||
|
|
||
| int seqId, | ||
|
|
||
| String input, | ||
|
|
||
| String expectedOutput, | ||
|
|
||
| String status | ||
|
|
||
| ) { | ||
| public static List<InitTestcaseListPayload> from(ProblemInfo info) { | ||
| return IntStream.rangeClosed(1, info.getTestcaseCount()) | ||
| .mapToObj(seq -> { | ||
| Testcase tc = info.testcaseList().get(seq - 1); | ||
| return new InitTestcaseListPayload( | ||
| seq, | ||
| tc.getInput(), | ||
| tc.getOutput(), | ||
| "채점 중" | ||
| ); | ||
| }) | ||
| .toList(); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
...zcode/codetest/application/submission/dto/event/payload/SubmissionFinalResultPayload.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.ezcode.codetest.application.submission.dto.event.payload; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| public class SubmissionFinalResultPayload { | ||
|
|
||
| private final int totalCount; | ||
|
|
||
| private final int passedCount; | ||
|
|
||
| private final boolean isCorrect; | ||
|
|
||
| private final String message; | ||
|
|
||
| public SubmissionFinalResultPayload(int totalCount, int passedCount, String message) { | ||
| this.totalCount = totalCount; | ||
| this.passedCount = passedCount; | ||
| this.isCorrect = totalCount == passedCount; | ||
| this.message = message; | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
...a/org/ezcode/codetest/application/submission/dto/event/payload/TestcaseResultPayload.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package org.ezcode.codetest.application.submission.dto.event.payload; | ||
|
|
||
| import org.ezcode.codetest.application.submission.model.JudgeResult; | ||
| import org.ezcode.codetest.domain.submission.dto.AnswerEvaluation; | ||
|
|
||
| public record TestcaseResultPayload( | ||
|
|
||
| int seqId, | ||
|
|
||
| boolean isPassed, | ||
|
|
||
| String actualOutput, | ||
|
|
||
| long executionTime, | ||
|
|
||
| long memoryUsage, | ||
|
|
||
| String message | ||
|
|
||
| ) { | ||
| public static TestcaseResultPayload fromEvaluation(int seqId, JudgeResult result, AnswerEvaluation evaluation) { | ||
| return new TestcaseResultPayload( | ||
| seqId, | ||
| evaluation.isPassed(), | ||
| result.actualOutput(), | ||
| result.executionTime(), | ||
| result.memoryUsage(), | ||
| result.message()); | ||
| } | ||
| } |
28 changes: 0 additions & 28 deletions
28
...g/ezcode/codetest/application/submission/dto/response/submission/FinalResultResponse.java
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
...g/ezcode/codetest/application/submission/dto/response/submission/JudgeResultResponse.java
This file was deleted.
Oops, something went wrong.
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
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
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
17 changes: 0 additions & 17 deletions
17
src/main/java/org/ezcode/codetest/application/submission/port/EmitterStore.java
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
src/main/java/org/ezcode/codetest/application/submission/port/ProblemEventService.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package org.ezcode.codetest.application.submission.port; | ||
|
|
||
| import org.ezcode.codetest.domain.submission.model.entity.UserProblemResult; | ||
|
|
||
| public interface ProblemEventService { | ||
|
|
||
| void publishProblemSolveEvent(UserProblemResult event); | ||
|
|
||
| } |
2 changes: 1 addition & 1 deletion
2
src/main/java/org/ezcode/codetest/application/submission/port/QueueProducer.java
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
17 changes: 17 additions & 0 deletions
17
src/main/java/org/ezcode/codetest/application/submission/port/SubmissionEventService.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.ezcode.codetest.application.submission.port; | ||
|
|
||
| import org.ezcode.codetest.application.submission.dto.event.SubmissionErrorEvent; | ||
| import org.ezcode.codetest.application.submission.dto.event.SubmissionJudgingFinishedEvent; | ||
| import org.ezcode.codetest.application.submission.dto.event.TestcaseListInitializedEvent; | ||
| import org.ezcode.codetest.application.submission.dto.event.TestcaseEvaluatedEvent; | ||
|
|
||
| public interface SubmissionEventService { | ||
|
|
||
| void publishInitTestcases(TestcaseListInitializedEvent event); | ||
|
|
||
| void publishTestcaseUpdate(TestcaseEvaluatedEvent event); | ||
|
|
||
| void publishFinalResult(SubmissionJudgingFinishedEvent event); | ||
|
|
||
| void publishSubmissionError(SubmissionErrorEvent event); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
안전하지 않은 캐스팅을 수정해주세요.
19번 라인의
(SubmissionExceptionCode) se.getResponseCode()캐스팅이 안전하지 않습니다.getResponseCode()가SubmissionExceptionCode를 반환한다는 보장이 없어ClassCastException이 발생할 수 있습니다.다음과 같이 안전한 캐스팅으로 수정하는 것을 권장합니다:
📝 Committable suggestion
🤖 Prompt for AI Agents
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.
나중에 SubmissionException으로 JudgeClient에서 다 랩핑해서 넘길 거야
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.
@thezz9 아, 그렇다면 현재 코드는 그대로 두시고 향후 JudgeClient에서 모든 예외를 SubmissionException으로 래핑해서 넘겨주시면 이 캐스팅 문제가 자연스럽게 해결되겠네요! 👍
✏️ Learnings added