feat: let asynq retry submit request if it's internal error
This commit is contained in:
parent
7be0379e30
commit
7446ac6d23
@ -44,26 +44,31 @@ func (h *handler) Judge(_ context.Context, t *asynq.Task) error {
|
||||
if !h.runnerService.ProblemExists(p.ProblemVersionID) {
|
||||
url, status := h.storageService.Get(p.StorageKey, time.Second*60*5)
|
||||
if status != e.Success {
|
||||
return e.InternalError, 0, systemError
|
||||
return status, 0, systemError
|
||||
}
|
||||
|
||||
_, status = h.runnerService.NewProblem(p.ProblemVersionID, url, false)
|
||||
if status != e.Success {
|
||||
return e.InternalError, 0, systemError
|
||||
return status, 0, systemError
|
||||
}
|
||||
}
|
||||
|
||||
// 3. compile
|
||||
compileResult, status := h.runnerService.Compile(p.ProblemVersionID, user, p.Submission.Language)
|
||||
if status != e.Success {
|
||||
return e.InternalError, 0, compileResult
|
||||
return status, 0, compileResult
|
||||
}
|
||||
|
||||
// 4. run and judge
|
||||
result, point, status := h.runnerService.RunAndJudge(p.ProblemVersionID, user, p.Submission.Language)
|
||||
return utils.If(status != e.Success, e.InternalError, e.Success), point, result
|
||||
return status, point, result
|
||||
}()
|
||||
|
||||
if status == e.InternalError {
|
||||
// notice asynq to retry
|
||||
return fmt.Errorf("internal error, ctx: %v", ctx)
|
||||
}
|
||||
|
||||
h.taskService.SubmitUpdate(&model.SubmitUpdatePayload{
|
||||
Status: status,
|
||||
SubmissionID: p.Submission.ID,
|
||||
|
Loading…
Reference in New Issue
Block a user