-
Notifications
You must be signed in to change notification settings - Fork 1
/
job.go
87 lines (63 loc) · 2.07 KB
/
job.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package ugrade
import (
"context"
"time"
"golang.org/x/xerrors"
)
// ErrCompilationError indicates program source code cannot compiled.
var ErrCompilationError = xerrors.New("compile error")
// Verdict represent verdict of submission.
type Verdict string
const (
// VerdictCE stands for Compilation Error.
VerdictCE = Verdict("CE")
// VerdictIE stands for Internal Error.
VerdictIE = Verdict("IE")
// VerdictRTE stands for Run Time Error.
VerdictRTE = Verdict("RTE")
// VerdictMLE stands for Memory Limit Exceeded.
VerdictMLE = Verdict("MLE")
// VerdictTLE stands for Time Limit Exceeded.
VerdictTLE = Verdict("TLE")
// VerdictWA stands for Wrong Answer.
VerdictWA = Verdict("WA")
// VerdictPENDING indicating that job is not graded yet.
VerdictPENDING = Verdict("PENDING")
// VerdictAC stands for Accepted.
VerdictAC = Verdict("AC")
)
// SourceCode represent program's source code.
type SourceCode struct {
// Path contains absolute path to source code file.
Path string
// Language contains language id of source code program.
Language string
}
// JobSpec represent job specification from ugrade server.
type JobSpec struct {
// TCGen represent testcase generator used for generating testcase input files.
TCGen SourceCode
// Solution represent jury solution.
Solution SourceCode
// Checker represent checker program to check correctness of contestant submissions by
// comparing to jury outputs.
Checker SourceCode
// Submission represent contestant program solution.
Submission SourceCode
// TimeLimit represent maximum time allowed for solution to be executed.
TimeLimit time.Duration
// OutputLimit represent maximum output generated by programs.
OutputLimit uint64
// MemoryLimit represent maximum allowed memory used by program.
MemoryLimit uint64
// Tolerance represent tolerance factor of problem.
Tolerance float64
}
// JobResult represent job result generated by worker.
type JobResult struct {
Verdict Verdict
}
// JobSolver solve job and gives result.
type JobSolver interface {
Solve(ctx context.Context, spec JobSpec) (*JobResult, error)
}